rip bug, mjr errstr hndl: string? adminright msg?
This commit is contained in:
parent
a50f53dcc1
commit
027400d763
1 changed files with 39 additions and 28 deletions
67
main.cpp
67
main.cpp
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#define log_debugc(str, ...) do { if (debug) fprintf(stdout, "[DEBUG] (%s:%d): " (str) "\n", __FILE__, __LINE__, ##__VA_ARGS__); } while (0)
|
#define log_debugc(str, ...) do { if (debug) fprintf(stdout, "[DEBUG] (%s:%d): " (str) "\n", __FILE__, __LINE__, ##__VA_ARGS__); } while (0)
|
||||||
#define log_debugcpp(str) do { \
|
#define log_debugcpp(str) do { \
|
||||||
if (debug) std::cout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << (str) << std::endl; \
|
if (debug) std::cout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define log_directory(str) if(debugVerbosity & DEBUG_DIRECTORY) log_debugcpp((str))
|
#define log_directory(str) if(debugVerbosity & DEBUG_DIRECTORY) log_debugcpp((str))
|
||||||
#define log_volume(str) if(debugVerbosity & DEBUG_VOLUME) log_debugcpp((str))
|
#define log_volume(str) if(debugVerbosity & DEBUG_VOLUME) log_debugcpp((str))
|
||||||
|
|
@ -61,6 +61,20 @@ typedef struct {
|
||||||
|
|
||||||
} directoriesInfo;
|
} directoriesInfo;
|
||||||
|
|
||||||
|
struct ErrorMessages{
|
||||||
|
const std::string addrBarError = "Failed to open folder: invalid path";
|
||||||
|
const std::string tableElementError = "Failed to open folder: access restricted to non-admin users";
|
||||||
|
const std::string listDirectoryError = "Failed to open folder: access denied";
|
||||||
|
const std::string moveUpError = "Failed to move up: reached volume root?";
|
||||||
|
};
|
||||||
|
|
||||||
|
// struct ErrorMessages{
|
||||||
|
// static constexpr char addrBarError[] = "Failed to open folder: invalid path";
|
||||||
|
// static constexpr char tableElementError[] = "Failed to open folder: access restricted to non-admin users";
|
||||||
|
// static constexpr char listDirectoryError[] = "Failed to open folder: access denied";
|
||||||
|
// static constexpr char moveUpError[] = "Failed to move up: reached volume root?";
|
||||||
|
// };
|
||||||
|
|
||||||
//TODO UNICORDEO
|
//TODO UNICORDEO
|
||||||
/* FILE PICKER MOMENTO */
|
/* FILE PICKER MOMENTO */
|
||||||
|
|
||||||
|
|
@ -153,9 +167,7 @@ int explodePaths(TCHAR* volumePaths, int volumePathsBufferSize, char separator,
|
||||||
itemPath[pathLengthIdx + 1] = '\0';
|
itemPath[pathLengthIdx + 1] = '\0';
|
||||||
dest->push_back(itemPath);
|
dest->push_back(itemPath);
|
||||||
//TODO concat de puto C
|
//TODO concat de puto C
|
||||||
log_debugcpp(dest->at(dest->size() - 1));
|
log_debugcpp(dest->at(dest->size() - 1) << " EXPLODEPATH");
|
||||||
log_debugcpp( " EXPLODEPATH");
|
|
||||||
|
|
||||||
|
|
||||||
if (nextOcurrence[0] == nextOcurrence[1]) return depth;
|
if (nextOcurrence[0] == nextOcurrence[1]) return depth;
|
||||||
depth++;
|
depth++;
|
||||||
|
|
@ -177,10 +189,9 @@ int listVolumes(std::vector<char*> *onPresentPaths){
|
||||||
TCHAR volumePaths[volumePathsBufferSize];
|
TCHAR volumePaths[volumePathsBufferSize];
|
||||||
std::fill(volumePaths, volumePaths + volumePathsBufferSize, '\0');
|
std::fill(volumePaths, volumePaths + volumePathsBufferSize, '\0');
|
||||||
|
|
||||||
hFind = FindFirstVolume(volumeName, volumeNameSize); //if (debug) std::cout << volumeNameSize << std::endl;
|
hFind = FindFirstVolume(volumeName, volumeNameSize);
|
||||||
if (INVALID_HANDLE_VALUE == hFind) return -2;
|
if (INVALID_HANDLE_VALUE == hFind) return -2;
|
||||||
do {
|
do {
|
||||||
//if (debug) std::cout << volumeName << std::endl;
|
|
||||||
|
|
||||||
if(GetVolumePathNamesForVolumeName(volumeName, volumePaths, volumePathsBufferSize, &volumePathLength)){
|
if(GetVolumePathNamesForVolumeName(volumeName, volumePaths, volumePathsBufferSize, &volumePathLength)){
|
||||||
|
|
||||||
|
|
@ -233,8 +244,7 @@ bool compareLastChar(std::vector<std::string> *lastCharCandidates, char* string)
|
||||||
if(strlen(string) < lastCharCandidates->at(i).length()) continue;
|
if(strlen(string) < lastCharCandidates->at(i).length()) continue;
|
||||||
char* potentialExtension = &string[strlen(string) - lastCharCandidates->at(i).length()];
|
char* potentialExtension = &string[strlen(string) - lastCharCandidates->at(i).length()];
|
||||||
|
|
||||||
log_debugcpp(potentialExtension);
|
log_debugcpp(potentialExtension << " LEN " + std::to_string(strlen(potentialExtension)) + " <- VS -> " + lastCharCandidates->at(i) + " LEN " + std::to_string(lastCharCandidates->at(i).length()));
|
||||||
log_debugcpp(" LEN " + std::to_string(strlen(potentialExtension)) + " <- VS -> " + lastCharCandidates->at(i) + " LEN " + std::to_string(lastCharCandidates->at(i).length()));
|
|
||||||
//+ strlen(potentialExtension) + std::to_string(lastCharCandidates->at(i).length())
|
//+ strlen(potentialExtension) + std::to_string(lastCharCandidates->at(i).length())
|
||||||
if(!strcmp(potentialExtension, lastCharCandidates->at(i).c_str())) {
|
if(!strcmp(potentialExtension, lastCharCandidates->at(i).c_str())) {
|
||||||
log_debugcpp("VALID EXTENSION");
|
log_debugcpp("VALID EXTENSION");
|
||||||
|
|
@ -250,6 +260,12 @@ bool inputMove(bool* error, char** str){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleFolderAccessResult(bool isListDirectoriesAdequate, char* currentPath, char* addrBarVal, char* errorDest, const char* errorContent){
|
||||||
|
if (isListDirectoriesAdequate) strcpy(currentPath, addrBarVal);
|
||||||
|
else strcpy(addrBarVal, currentPath);
|
||||||
|
strcpy(errorDest, errorContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIN FILE PICKER MOMENTO */
|
/* FIN FILE PICKER MOMENTO */
|
||||||
|
|
||||||
|
|
@ -372,9 +388,10 @@ int main(int, char**)
|
||||||
ImGui::Begin("File Picker in 4K");
|
ImGui::Begin("File Picker in 4K");
|
||||||
|
|
||||||
static bool showError = false;
|
static bool showError = false;
|
||||||
|
static char error[MAX_ERRORSTR_LEN];
|
||||||
|
static ErrorMessages eMsg;
|
||||||
static bool isListVolumesAdequate = true;
|
static bool isListVolumesAdequate = true;
|
||||||
static bool isListDirectoriesAdequate = true;
|
static bool isListDirectoriesAdequate = true;
|
||||||
static char error[MAX_ERRORSTR_LEN];
|
|
||||||
|
|
||||||
//Listar UNA VEZ volumenes
|
//Listar UNA VEZ volumenes
|
||||||
static int numVolumes;
|
static int numVolumes;
|
||||||
|
|
@ -417,7 +434,7 @@ int main(int, char**)
|
||||||
if (numFiles < 0) {
|
if (numFiles < 0) {
|
||||||
log_debugcpp("FALLO LA FUNCION, VALOR NEGATIVO " + std::to_string(numFiles));
|
log_debugcpp("FALLO LA FUNCION, VALOR NEGATIVO " + std::to_string(numFiles));
|
||||||
showError = true;
|
showError = true;
|
||||||
strcpy(error, "Failed to open folder: permission denied?");
|
strcpy(error, eMsg.listDirectoryError.c_str());
|
||||||
strcpy(currentPath, addrBarVal);
|
strcpy(currentPath, addrBarVal);
|
||||||
numFiles = listDirectory(std::string(currentPath), &directoryContents);
|
numFiles = listDirectory(std::string(currentPath), &directoryContents);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -443,31 +460,26 @@ int main(int, char**)
|
||||||
static char* moveUpPtr = &moveUp[0];
|
static char* moveUpPtr = &moveUp[0];
|
||||||
if(ImGui::Button("Move Up")) {
|
if(ImGui::Button("Move Up")) {
|
||||||
isListDirectoriesAdequate = inputMove(&showError, (&moveUpPtr));
|
isListDirectoriesAdequate = inputMove(&showError, (&moveUpPtr));
|
||||||
strcpy(error, "Failed to move up: reached volume root?");
|
strcpy(error, eMsg.moveUpError.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
//BARRA DE DIRECCIONES
|
//BARRA DE DIRECCIONES
|
||||||
|
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("Enter").x + ImGui::GetStyle().ItemSpacing.x * 2) );
|
||||||
if(ImGui::InputText("##addrbar", addrBarVal, IM_ARRAYSIZE(addrBarVal), ImGuiInputTextFlags_EnterReturnsTrue )){
|
if(ImGui::InputText("##addrbar", addrBarVal, IM_ARRAYSIZE(addrBarVal), ImGuiInputTextFlags_EnterReturnsTrue )){
|
||||||
log_debugcpp(currentPath);
|
log_debugcpp(currentPath <<" ADDRBAR INTENTO");
|
||||||
log_debugcpp(" ADDRBAR INTENTO");
|
|
||||||
isListDirectoriesAdequate = inputMove(&showError, &addrBarValPtr);
|
isListDirectoriesAdequate = inputMove(&showError, &addrBarValPtr);
|
||||||
if (isListDirectoriesAdequate) strcpy(currentPath, addrBarVal);
|
handleFolderAccessResult(isListDirectoriesAdequate, currentPath, addrBarVal, error, eMsg.addrBarError.c_str());
|
||||||
else strcpy(addrBarVal, currentPath);
|
|
||||||
strcpy(error, "Failed to open folder: invalid path");
|
|
||||||
};
|
};
|
||||||
|
ImGui::PopItemWidth();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("Enter")){
|
if(ImGui::Button("Enter")){
|
||||||
log_debugcpp(currentPath);
|
log_debugcpp(currentPath <<" ADDRBAR INTENTO");
|
||||||
log_debugcpp(" ADDRBAR INTENTO");
|
|
||||||
isListDirectoriesAdequate = inputMove(&showError, &addrBarValPtr);
|
isListDirectoriesAdequate = inputMove(&showError, &addrBarValPtr);
|
||||||
if (isListDirectoriesAdequate) strcpy(currentPath, addrBarVal);
|
handleFolderAccessResult(isListDirectoriesAdequate, currentPath, addrBarVal, error, eMsg.addrBarError.c_str());
|
||||||
else strcpy(addrBarVal, currentPath);
|
|
||||||
strcpy(error, "Failed to open folder: invalid path");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//ImGui::Text("%s TEMPADDRBAR", currentPath);
|
//ImGui::Text("%s TEMPADDRBAR", currentPath);
|
||||||
|
log_debugcpp(currentPath <<" LEMISIIMIA");
|
||||||
//LA GRAN TABLACIÓN: ACTOR EN LAS SOMBRAS
|
//LA GRAN TABLACIÓN: ACTOR EN LAS SOMBRAS
|
||||||
static ImGuiTableFlags splitterTableFlags = ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV;
|
static ImGuiTableFlags splitterTableFlags = ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV;
|
||||||
if (ImGui::BeginTable("##splitterTable", 2, splitterTableFlags, ImVec2(-FLT_MIN, 0.8f * ImGui::GetTextLineHeightWithSpacing()))){
|
if (ImGui::BeginTable("##splitterTable", 2, splitterTableFlags, ImVec2(-FLT_MIN, 0.8f * ImGui::GetTextLineHeightWithSpacing()))){
|
||||||
|
|
@ -530,11 +542,10 @@ int main(int, char**)
|
||||||
//NAME
|
//NAME
|
||||||
bool isSelected = false;
|
bool isSelected = false;
|
||||||
if (ImGui::Selectable(directoryContents.at(idx)->name, &isSelected)){
|
if (ImGui::Selectable(directoryContents.at(idx)->name, &isSelected)){
|
||||||
//currentItemIdx = i;
|
strcat(addrBarVal, "\\");
|
||||||
strcat(currentPath, "\\");
|
strcat(addrBarVal, directoryContents.at(idx)->name);
|
||||||
strcat(currentPath, directoryContents.at(idx)->name);
|
isListDirectoriesAdequate = inputMove(&showError, &addrBarValPtr);
|
||||||
isListDirectoriesAdequate = inputMove(&showError, ¤tPathPtr);
|
handleFolderAccessResult(isListDirectoriesAdequate, currentPath, addrBarVal, error, eMsg.tableElementError.c_str());
|
||||||
strcpy(error, "Failed to open folder: invalid option");
|
|
||||||
//currentItemIdx = -1;
|
//currentItemIdx = -1;
|
||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue