Debug verbosity, modified README
This commit is contained in:
parent
809a5abcd5
commit
19f09f208f
3 changed files with 136 additions and 92 deletions
49
README.md
49
README.md
|
|
@ -1,45 +1,58 @@
|
||||||
Single-header file picker Windows library for ImGui.
|
Single-header file picker library for ImGui.
|
||||||
|
|
||||||
|
Currently, this library is Windows-only. Support for Linux is planned.
|
||||||
|
|
||||||
# How to use
|
# How to use
|
||||||
|
|
||||||
int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0) {
|
This library exposes two functions:
|
||||||
|
|
||||||
Call `int fp::renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0);` within the render loop providing a pre-allocated C-string buffer of MAX_PATH characters in `userPath`. `windowOpen` must be initially set to `true`, and will set itself to `false` when execution is done. If succesful, your buffer will contain a valid path. You can check the file picker state each frame by parsing this function's return value. You can provide `windowFlags` to customize its appearance.
|
##int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0);
|
||||||
|
|
||||||
## Window states
|
Call this function within the render loop providing a pre-allocated C-wide string buffer of MAX_PATH characters in `userPath`. `windowOpen` must be initially set to `true`, and will set itself to `false` when execution is done. If succesful, your buffer will contain a valid path. You can check the file picker state each frame by parsing this function's return value. You can provide `windowFlags` to customize its appearance.
|
||||||
|
|
||||||
|
### Window customization flags
|
||||||
```
|
```
|
||||||
- fp::ExitFlags::EXIT_CONTINUE : Window will render next frame.
|
fp::WindowFlags::FULLSCREEN : Render window in full screen, without decorations.
|
||||||
- fp::ExitFlags::EXIT_SELECTED : A path has been successfully returned, window will close.
|
|
||||||
- fp::ExitFlags::EXIT_CLOSED : User has closed the window. No path is returned.
|
|
||||||
- fp::ExitFlags::EXIT_ERROR : An unexpected error has ocurred. No path is returned.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Valid window flags
|
### Return values
|
||||||
|
|
||||||
```
|
```
|
||||||
- fp::WindowFlags::FP_FULLSCREEN`: Render window in full screen, without decorations.
|
fp::ExitFlags::CONTINUE : Window will render next frame.
|
||||||
|
fp::ExitFlags::SELECTED : A path has been successfully returned, window will close.
|
||||||
|
fp::ExitFlags::CLOSED : User has closed the window. No path is returned.
|
||||||
|
```
|
||||||
|
|
||||||
|
##void setDebugInfo(int debugVerbosity);
|
||||||
|
|
||||||
|
When `FPDEBUG` is enabled, this allows you to configure debug granularity.
|
||||||
|
|
||||||
|
### Debug flags
|
||||||
|
|
||||||
|
```
|
||||||
|
fp::DebugVerbosity::DIRECTORY
|
||||||
|
fp::DebugVerbosity::VOLUME
|
||||||
|
fp::DebugVerbosity::EXTENSION
|
||||||
```
|
```
|
||||||
|
|
||||||
# Library dependencies
|
# Library dependencies
|
||||||
|
|
||||||
- **C++ STL**: This library uses `vector` and `w\string`.
|
- **C++ STL**: This library uses `vector` and `w\string`.
|
||||||
|
|
||||||
## Build considerations
|
## Enable debug information
|
||||||
|
|
||||||
Define `DEBUG` to print relevant information to the console.
|
Define `FPDEBUG` to print relevant information to the console.
|
||||||
|
|
||||||
# Demo build instructions
|
# Demo build instructions
|
||||||
|
|
||||||
## Build requirements
|
## Build requirements
|
||||||
|
|
||||||
- [**GLFW v3**](https://github.com/glfw/glfw/releases): used as rendering backend. Executable in releases is compiled with version [`3.3.8`](https://github.com/glfw/glfw/releases/tag/3.3.8).
|
- [**GLFW v3**](https://github.com/glfw/glfw/releases): used as rendering backend. Executable in releases is compiled with version [`3.3.8`](https://github.com/glfw/glfw/releases/tag/3.3.8).
|
||||||
- Compiled with `clang` using [**llvm-mingw 20220906**](https://github.com/mstorsjo/llvm-mingw/releases/tag/20220906).
|
- Developed and tested with `clang` using [**llvm-mingw 20220906**](https://github.com/mstorsjo/llvm-mingw/releases/tag/20220906). Any `MinGW`-backed `clang` compiler should work, but your mileage may vary.
|
||||||
|
|
||||||
## How to compile
|
## How to compile
|
||||||
|
|
||||||
Download GLFW and pick your libraries according to your toolchain(`mingw-w64` in this example).
|
Download GLFW and pick your libraries according to your toolchain. Then, call your compiler directly specifying both libs needed and your paths to the necessary header and lib files:
|
||||||
|
|
||||||
Then, call your compiler directly (`clang` is demonstrated here) specifying both libs needed and your paths to the necessary header and lib files:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
clang++ demo/main.cpp -o demo/demo.exe -L C:/pathtollvmmingw/x86_64-w64-mingw32/bin -I C:\pathtollvmmingw\include -L C:/pathtoglfw/lib-mingw-w64 -I C:\pathtoglfw\include -lglfw3 -l libc++
|
clang++ demo/main.cpp -o demo/demo.exe -L C:/pathtollvmmingw/x86_64-w64-mingw32/bin -I C:\pathtollvmmingw\include -L C:/pathtoglfw/lib-mingw-w64 -I C:\pathtoglfw\include -lglfw3 -l libc++
|
||||||
|
|
@ -48,10 +61,8 @@ int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0) {
|
||||||
If you want to statically link:
|
If you want to statically link:
|
||||||
|
|
||||||
```
|
```
|
||||||
clang++ demo/main.cpp -o demo/si.exe -DDEBUG -L C:\capybara\libclang\x86_64-w64-mingw32\bin -L C:\capybara\libclang\x86_64-w64-mingw32\lib -I C:\capybara\libclang\include -std=c++17 -lglfw3 -l opengl32 -l gdi32 -l user32 -l kernel32 -l imm32 -static-libstdc++ --verbose
|
clang++ demo/main.cpp -o demo/demo.exe -L C:/pathtoglfw/lib-mingw-w64 -L C:/pathtollvmmingw/x86_64-w64-mingw32/lib -I C:\pathtollvmmingw\include -I C:\pathtoglfw\include -std=c++17 -stdlib=libc++ -rtlib=compiler-rt -static -l glfw3 -l gdi32 -l opengl32 -l user32 -l kernel32 -static-libstdc++
|
||||||
```
|
```
|
||||||
|
|
||||||
Add `-DDEBUG` to print filepicker's debug information, if you so desire.
|
|
||||||
|
|
||||||
# To-Dos
|
# To-Dos
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
//Demo executable based on GLFW
|
//Demo executable based on GLFW
|
||||||
|
|
||||||
#define IMGUI_IMPLEMENTATION
|
#define IMGUI_IMPLEMENTATION
|
||||||
#define GL_SILENCE_DEPRECATION
|
#define GL_SILENCE_DEPRECATION
|
||||||
|
|
||||||
|
|
@ -40,7 +39,7 @@ int main(int, char**) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create window with graphics context
|
// Create window with graphics context
|
||||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL3 example", NULL, NULL);
|
GLFWwindow* window = glfwCreateWindow(1280, 720, "File Picker Demo", NULL, NULL);
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
@ -76,12 +75,21 @@ int main(int, char**) {
|
||||||
|
|
||||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
static wchar_t path[MAX_PATH];// = malloc(MAX_PATH * sizeof(char));
|
static wchar_t path[MAX_PATH];// = malloc(MAX_PATH * sizeof(char));
|
||||||
|
static int state;
|
||||||
|
static int debugVerbosity = fp::DebugVerbosity::DIRECTORY | fp::DebugVerbosity::VOLUME | fp::DebugVerbosity::EXTENSION;
|
||||||
|
//debugVerbosity = 0;
|
||||||
static bool windowOpen = true;
|
static bool windowOpen = true;
|
||||||
|
fp::setDebugInfo(debugVerbosity);
|
||||||
if(windowOpen)
|
if(windowOpen)
|
||||||
fp::renderFilePicker(&path[0], &windowOpen, 0);
|
state = fp::renderFilePicker(&path[0], &windowOpen, 0);
|
||||||
|
|
||||||
if (show_demo_window)
|
//if (show_demo_window)
|
||||||
ImGui::ShowDemoWindow(&show_demo_window);
|
ImGui::SetNextWindowSize(ImVec2(500.0f, 500.0f));
|
||||||
|
ImGui::Begin("Values", NULL, 0);
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
|
ImGui::PopStyleVar(1);
|
||||||
|
ImGui::End();
|
||||||
|
//ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
|
||||||
159
filepicker.hpp
159
filepicker.hpp
|
|
@ -1,5 +1,5 @@
|
||||||
//DEBUG MACRO
|
//DEBUG MACRO
|
||||||
#ifdef DEBUG
|
#ifdef FPDEBUG
|
||||||
#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; \
|
||||||
|
|
@ -7,9 +7,24 @@
|
||||||
#define log_wdebugcpp(str) do { \
|
#define log_wdebugcpp(str) do { \
|
||||||
if (debug) std::wcout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
if (debug) std::wcout << "[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) do { \
|
||||||
#define log_volume(str) if(debugVerbosity & DEBUG_VOLUME) log_debugcpp((str))
|
if(debugVerbosity & DIRECTORY) log_debugcpp(str); \
|
||||||
#define log_extension(str) if(debugVerbosity & DEBUG_EXTENSION) log_debugcpp((str))
|
} while (0)
|
||||||
|
#define log_volume(str) do { \
|
||||||
|
if(debugVerbosity & VOLUME) log_debugcpp(str); \
|
||||||
|
} while (0)
|
||||||
|
#define log_extension(str) do { \
|
||||||
|
if(debugVerbosity & EXTENSION) log_debugcpp(str); \
|
||||||
|
} while (0)
|
||||||
|
#define log_wdirectory(str) do { \
|
||||||
|
if(debugVerbosity & DIRECTORY) log_wdebugcpp(str); \
|
||||||
|
} while (0)
|
||||||
|
#define log_wvolume(str) do { \
|
||||||
|
if(debugVerbosity & VOLUME) log_wdebugcpp(str); \
|
||||||
|
} while (0)
|
||||||
|
#define log_wextension(str) do { \
|
||||||
|
if(debugVerbosity & EXTENSION) log_wdebugcpp(str); \
|
||||||
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define log_debugc(str, ...)
|
#define log_debugc(str, ...)
|
||||||
#define log_debugcpp(str)
|
#define log_debugcpp(str)
|
||||||
|
|
@ -17,6 +32,9 @@
|
||||||
#define log_directory(str)
|
#define log_directory(str)
|
||||||
#define log_volume(str)
|
#define log_volume(str)
|
||||||
#define log_extension(str)
|
#define log_extension(str)
|
||||||
|
#define log_wdirectory(str)
|
||||||
|
#define log_wvolume(str)
|
||||||
|
#define log_wextension(str)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//PATH MACRO
|
//PATH MACRO
|
||||||
|
|
@ -62,6 +80,11 @@ struct History {
|
||||||
int historyDepth;
|
int historyDepth;
|
||||||
int historyTraversalPos;
|
int historyTraversalPos;
|
||||||
bool isAdditionTime;
|
bool isAdditionTime;
|
||||||
|
|
||||||
|
History(){
|
||||||
|
historyTraversalPos = historyDepth = -1;
|
||||||
|
isAdditionTime = true;
|
||||||
|
}
|
||||||
|
|
||||||
// wchar* operator[](int idx){
|
// wchar* operator[](int idx){
|
||||||
// if (idx > previousPaths.size())
|
// if (idx > previousPaths.size())
|
||||||
|
|
@ -79,19 +102,16 @@ struct History {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
History(){
|
|
||||||
historyTraversalPos = historyDepth = -1;
|
|
||||||
isAdditionTime = true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum HistoryMovement {
|
enum HistoryMovement {
|
||||||
HISTORY_FORWARD = 1,
|
HISTORY_FORWARD = 1,
|
||||||
HISTORY_BACKWARD = 0
|
HISTORY_BACKWARD = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ListDirectoryError {
|
enum ListDirectoryError {
|
||||||
DIRECTORY_ERROR_PATH_TOO_LONG = -1,
|
DIRECTORY_ERROR_PATH_TOO_LONG = -1,
|
||||||
DIRECTORY_ERROR_ACCESSING_CONTENT = -2
|
DIRECTORY_ERROR_ACCESSING_CONTENT = -2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -100,41 +120,46 @@ enum AgnosticDirError {
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ErrorMessages {
|
namespace ErrorMessages {
|
||||||
char addrBarError[] = "Failed to open folder: invalid path";
|
char addrBarError[] = "Failed to open folder: invalid path";
|
||||||
char tableElementError[] = "Failed to open folder: access restricted to non-admin users";
|
char tableElementError[] = "Failed to open folder: access restricted to non-admin users";
|
||||||
char accessDeniedError[] = "Failed to open folder: access denied";
|
char accessDeniedError[] = "Failed to open folder: access denied";
|
||||||
char listDirectoryError[] = "Failed to open folder: unknown error";
|
char listDirectoryError[] = "Failed to open folder: unknown error";
|
||||||
char moveUpError[] = "Failed to move up: reached volume root?";
|
char moveUpError[] = "Failed to move up: reached volume root?";
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Label {
|
namespace Label {
|
||||||
wchar_t saveFileLabel[] = L"Save file: ";
|
wchar_t saveFileLabel[] = L"Save file: ";
|
||||||
wchar_t loadFileLabel[] = L"Select a file: ";
|
wchar_t loadFileLabel[] = L"Select a file: ";
|
||||||
wchar_t selectDirectoryLabel[] = L"Select a directory: ";
|
wchar_t selectDirectoryLabel[] = L"Select a directory: ";
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ListFlags {
|
enum ListFlags {
|
||||||
LIST_DIRECTORY = (1<<0),
|
LIST_DIRECTORY = (1<<0),
|
||||||
LIST_VOLUME = (1<<1)
|
LIST_VOLUME = (1<<1)
|
||||||
};
|
};
|
||||||
|
|
||||||
enum WindowFlags {
|
enum WindowFlags {
|
||||||
FP_FULLSCREEN = (1<<0),
|
FULLSCREEN = (1<<0),
|
||||||
FP_MODAL = (1<<1),
|
MODAL = (1<<1),
|
||||||
FP_FILE_LOAD = (1<<2),
|
FILE_LOAD = (1<<2),
|
||||||
FP_FILE_SAVE = (1<<3),
|
FILE_SAVE = (1<<3),
|
||||||
FP_DIRECTORY_SELECT = (1<<4)
|
DIRECTORY_SELECT = (1<<4)
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ExitFlags {
|
enum ExitFlags {
|
||||||
EXIT_CONTINUE = (1<<0),
|
CONTINUE = (1<<0),
|
||||||
EXIT_SELECTED = (1<<1),
|
SELECTED = (1<<1),
|
||||||
EXIT_CLOSED = (1<<2),
|
CLOSED = (1<<2)
|
||||||
EXIT_ERROR = (1<<3)
|
};
|
||||||
|
|
||||||
|
enum DebugVerbosity {
|
||||||
|
DIRECTORY = (1<<0),
|
||||||
|
VOLUME = (1<<1),
|
||||||
|
EXTENSION = (1<<2)
|
||||||
};
|
};
|
||||||
|
|
||||||
//VARS
|
//VARS
|
||||||
#ifdef DEBUG
|
#ifdef FPDEBUG
|
||||||
bool debug = true;
|
bool debug = true;
|
||||||
#else
|
#else
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
|
@ -193,18 +218,18 @@ std::vector<std::wstring> extensions;
|
||||||
|
|
||||||
History* history;
|
History* history;
|
||||||
|
|
||||||
// int debugVerbosity = 0;
|
int debugVerbosity = 0;
|
||||||
// enum enumDebugVerbosity {
|
|
||||||
// DEBUG_DIRECTORY = (1<<0),
|
|
||||||
// DEBUG_VOLUME = (1<<1),
|
|
||||||
// DEBUG_EXTENSION = (1<<2)
|
|
||||||
// };
|
|
||||||
// debugVerbosity = DEBUG_DIRECTORY | DEBUG_EXTENSION;
|
// debugVerbosity = DEBUG_DIRECTORY | DEBUG_EXTENSION;
|
||||||
// debugVerbosity &= ~DEBUG_DIRECTORY;
|
// debugVerbosity &= ~DEBUG_DIRECTORY;
|
||||||
// if (debugVerbosity & (DEBUG_DIRECTORY | DEBUG_EXTENSION));
|
// if (debugVerbosity & (DEBUG_DIRECTORY | DEBUG_EXTENSION));
|
||||||
|
|
||||||
//TODO UNICORDEO
|
/* DEBUG VERBOSITY */
|
||||||
/* FILE PICKER MOMENTO */
|
|
||||||
|
void setDebugInfo(int debugFlags) {
|
||||||
|
debugVerbosity = debugFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FILE PICKER MOMENTO */
|
||||||
|
|
||||||
|
|
||||||
/* DIRECTORIES */
|
/* DIRECTORIES */
|
||||||
|
|
@ -216,7 +241,7 @@ bool retrieveCurrentDirectory(wchar_t* currentPath){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool moveDirectory(wchar_t* currentPath){
|
bool moveDirectory(wchar_t* currentPath){
|
||||||
log_debugcpp(currentPath);
|
log_directory(currentPath);
|
||||||
if(SetCurrentDirectory(currentPath)) return true;
|
if(SetCurrentDirectory(currentPath)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +258,7 @@ int listDirectory(std::wstring path, std::vector<directoriesInfo*> *directoryCon
|
||||||
if (INVALID_HANDLE_VALUE == hFind) return DIRECTORY_ERROR_ACCESSING_CONTENT;
|
if (INVALID_HANDLE_VALUE == hFind) return DIRECTORY_ERROR_ACCESSING_CONTENT;
|
||||||
do {
|
do {
|
||||||
if(!wcscmp(ffd.cFileName, L".") || !wcscmp(ffd.cFileName, L"..")) continue;
|
if(!wcscmp(ffd.cFileName, L".") || !wcscmp(ffd.cFileName, L"..")) continue;
|
||||||
log_debugcpp("BUCLE listDirectory iteracion " + std::to_string(numFiles));
|
log_directory("BUCLE listDirectory iteracion " + std::to_string(numFiles));
|
||||||
|
|
||||||
directoriesInfo* itemInfo;
|
directoriesInfo* itemInfo;
|
||||||
if (directoryContents->size() <= numFiles){
|
if (directoryContents->size() <= numFiles){
|
||||||
|
|
@ -242,7 +267,7 @@ int listDirectory(std::wstring path, std::vector<directoriesInfo*> *directoryCon
|
||||||
} else {
|
} else {
|
||||||
itemInfo = directoryContents->at(numFiles);
|
itemInfo = directoryContents->at(numFiles);
|
||||||
}
|
}
|
||||||
log_debugcpp("MEMORY ASSIGNES iteration " + std::to_string(numFiles));
|
log_directory("MEMORY ASSIGNES iteration " + std::to_string(numFiles));
|
||||||
|
|
||||||
//A registrar info, fiera
|
//A registrar info, fiera
|
||||||
itemInfo->isFile = (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false;
|
itemInfo->isFile = (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false;
|
||||||
|
|
@ -263,7 +288,7 @@ int listDirectory(std::wstring path, std::vector<directoriesInfo*> *directoryCon
|
||||||
} while (ffd.cFileName[idx]);
|
} while (ffd.cFileName[idx]);
|
||||||
itemInfo->name[idx] = '\0';
|
itemInfo->name[idx] = '\0';
|
||||||
itemInfo->nameUTF8[idx] = '\0';
|
itemInfo->nameUTF8[idx] = '\0';
|
||||||
log_debugcpp("INFORMACION ALMACENADA iteracion " + std::to_string(numFiles));
|
log_directory("INFORMACION ALMACENADA iteracion " + std::to_string(numFiles));
|
||||||
|
|
||||||
numFiles++;
|
numFiles++;
|
||||||
} while (FindNextFile(hFind, &ffd) != 0);
|
} while (FindNextFile(hFind, &ffd) != 0);
|
||||||
|
|
@ -305,7 +330,7 @@ int explodePaths(wchar_t* volumePaths, int volumePathsBufferSize, wchar_t separa
|
||||||
|
|
||||||
int pathLengthIdx = 0;
|
int pathLengthIdx = 0;
|
||||||
for (; volumePaths[pathLengthIdx] != nextOcurrence[0]; pathLengthIdx++) {
|
for (; volumePaths[pathLengthIdx] != nextOcurrence[0]; pathLengthIdx++) {
|
||||||
log_debugcpp(volumePaths[0] << " ENTERS " << std::to_string(pathLengthIdx));
|
log_volume(volumePaths[0] << " ENTERS " << std::to_string(pathLengthIdx));
|
||||||
itemPath[pathLengthIdx] = volumePaths[pathLengthIdx];
|
itemPath[pathLengthIdx] = volumePaths[pathLengthIdx];
|
||||||
}
|
}
|
||||||
itemPath[pathLengthIdx + 1] = '\0';
|
itemPath[pathLengthIdx + 1] = '\0';
|
||||||
|
|
@ -315,8 +340,8 @@ int explodePaths(wchar_t* volumePaths, int volumePathsBufferSize, wchar_t separa
|
||||||
destUTF8->push_back(itemPathUTF8);
|
destUTF8->push_back(itemPathUTF8);
|
||||||
|
|
||||||
|
|
||||||
log_wdebugcpp(dest->at(dest->size() - 1) << L" EXPLODEPATH");
|
log_wvolume(dest->at(dest->size() - 1) << L" EXPLODEPATH");
|
||||||
log_debugcpp(dest->at(destUTF8->size() - 1) << " EXPLODEPATH");
|
log_volume(destUTF8->at(destUTF8->size() - 1) << " EXPLODEPATH");
|
||||||
|
|
||||||
if (nextOcurrence[0] == nextOcurrence[1]) return depth;
|
if (nextOcurrence[0] == nextOcurrence[1]) return depth;
|
||||||
depth++;
|
depth++;
|
||||||
|
|
@ -345,10 +370,10 @@ int listVolumes(std::vector<wchar_t*> *onPresentPaths, std::vector<char*> *onPre
|
||||||
if(GetVolumePathNamesForVolumeName(volumeName, volumePaths, volumePathsBufferSize, &volumePathLength)){
|
if(GetVolumePathNamesForVolumeName(volumeName, volumePaths, volumePathsBufferSize, &volumePathLength)){
|
||||||
|
|
||||||
if (volumePathLength == 1) {
|
if (volumePathLength == 1) {
|
||||||
log_debugcpp("Skill Issue");
|
log_volume("Skill Issue");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
log_debugcpp(volumeName);
|
log_volume(volumeName);
|
||||||
|
|
||||||
//DEBUG: pathSchecker
|
//DEBUG: pathSchecker
|
||||||
// if (debug && volumePaths[0] == 'E') {
|
// if (debug && volumePaths[0] == 'E') {
|
||||||
|
|
@ -365,21 +390,21 @@ int listVolumes(std::vector<wchar_t*> *onPresentPaths, std::vector<char*> *onPre
|
||||||
if (debug) {
|
if (debug) {
|
||||||
if(numVolumes += explodePaths(volumePaths, volumePathsBufferSize, separator, onPresentPaths, onPresentPathsUTF8)){
|
if(numVolumes += explodePaths(volumePaths, volumePathsBufferSize, separator, onPresentPaths, onPresentPathsUTF8)){
|
||||||
for (int i = 0; i < onPresentPaths->size(); i++){
|
for (int i = 0; i < onPresentPaths->size(); i++){
|
||||||
log_debugcpp(onPresentPaths->at(i));
|
log_volume(onPresentPaths->at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//std::cout << volumePaths << std::endl;
|
//std::cout << volumePaths << std::endl;
|
||||||
|
|
||||||
log_debugcpp(std::to_string(volumePathLength) + "<- VOLUME PATH LENGTH");
|
log_volume(std::to_string(volumePathLength) + "<- VOLUME PATH LENGTH");
|
||||||
log_debugcpp("THE END");
|
log_volume("THE END");
|
||||||
} else {
|
} else {
|
||||||
log_debugcpp("no volumes found");
|
log_volume("no volumes found");
|
||||||
}
|
}
|
||||||
//TODO benchimarqui
|
//TODO benchimarqui
|
||||||
std::fill(volumePaths, volumePaths + volumePathsBufferSize, '\0');
|
std::fill(volumePaths, volumePaths + volumePathsBufferSize, '\0');
|
||||||
} while (FindNextVolume(hFind, volumeName, volumeNameSize) != 0);
|
} while (FindNextVolume(hFind, volumeName, volumeNameSize) != 0);
|
||||||
log_debugcpp(std::to_string(onPresentPaths->size()) + " JUST BEFORE MAIN");
|
log_volume(std::to_string(onPresentPaths->size()) + " JUST BEFORE MAIN");
|
||||||
FindVolumeClose(hFind);
|
FindVolumeClose(hFind);
|
||||||
return numVolumes;
|
return numVolumes;
|
||||||
}
|
}
|
||||||
|
|
@ -391,15 +416,15 @@ int listVolumes(std::vector<wchar_t*> *onPresentPaths, std::vector<char*> *onPre
|
||||||
bool compareLastWchar(std::vector<std::wstring> *lastCharCandidates, wchar_t* string){
|
bool compareLastWchar(std::vector<std::wstring> *lastCharCandidates, wchar_t* string){
|
||||||
bool matchingExtension = false;
|
bool matchingExtension = false;
|
||||||
for (int i = 0; i < lastCharCandidates->size(); i++){
|
for (int i = 0; i < lastCharCandidates->size(); i++){
|
||||||
log_wdebugcpp(lastCharCandidates->at(i) + L" <- FILTERING EXTENSION");
|
log_wextension(lastCharCandidates->at(i) << L" <- FILTERING EXTENSION");
|
||||||
|
|
||||||
if(wcslen(string) < lastCharCandidates->at(i).length()) continue;
|
if(wcslen(string) < lastCharCandidates->at(i).length()) continue;
|
||||||
wchar_t* potentialExtension = &string[wcslen(string) - lastCharCandidates->at(i).length()];
|
wchar_t* potentialExtension = &string[wcslen(string) - lastCharCandidates->at(i).length()];
|
||||||
|
|
||||||
log_wdebugcpp(potentialExtension << L" LEN " + std::to_wstring(wcslen(potentialExtension)) + L" <- VS -> " + lastCharCandidates->at(i) + L" LEN " + std::to_wstring(lastCharCandidates->at(i).length()));
|
log_wextension(potentialExtension << L" LEN " + std::to_wstring(wcslen(potentialExtension)) + L" <- VS -> " + lastCharCandidates->at(i) + L" LEN " + std::to_wstring(lastCharCandidates->at(i).length()));
|
||||||
//+ strlen(potentialExtension) + std::to_string(lastCharCandidates->at(i).length())
|
//+ strlen(potentialExtension) + std::to_string(lastCharCandidates->at(i).length())
|
||||||
if(!wcscmp(potentialExtension, lastCharCandidates->at(i).c_str())) {
|
if(!wcscmp(potentialExtension, lastCharCandidates->at(i).c_str())) {
|
||||||
log_debugcpp("VALID EXTENSION");
|
log_extension("VALID EXTENSION");
|
||||||
matchingExtension = true;
|
matchingExtension = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -503,7 +528,7 @@ int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0) {
|
||||||
if (!windowConfigured) {
|
if (!windowConfigured) {
|
||||||
listFlags = LIST_DIRECTORY | LIST_VOLUME;
|
listFlags = LIST_DIRECTORY | LIST_VOLUME;
|
||||||
history = new History();
|
history = new History();
|
||||||
if (windowFlags & FP_FULLSCREEN){
|
if (windowFlags & FULLSCREEN){
|
||||||
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
|
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
|
||||||
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize);
|
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize);
|
||||||
windowFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize;
|
windowFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize;
|
||||||
|
|
@ -519,8 +544,8 @@ int renderFilePicker(wchar_t* userPath, bool* windowOpen, int windowFlags = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int exitWindow(wchar_t* userPath, bool* windowOpen, int exitFlag){
|
int exitWindow(wchar_t* userPath, bool* windowOpen, int exitFlag){
|
||||||
if(exitFlag & EXIT_SELECTED) {
|
if(exitFlag & SELECTED) {
|
||||||
if (chosenPath[0] == '\0') return EXIT_CONTINUE;
|
if (chosenPath[0] == '\0') return CONTINUE;
|
||||||
wcscpy(userPath, chosenPath);
|
wcscpy(userPath, chosenPath);
|
||||||
*windowOpen = false;
|
*windowOpen = false;
|
||||||
}
|
}
|
||||||
|
|
@ -547,7 +572,7 @@ int windowRendering(wchar_t* userPath, bool* windowOpen, int windowFlags = 0){
|
||||||
if (listFlags & LIST_VOLUME) {
|
if (listFlags & LIST_VOLUME) {
|
||||||
listFlags &= ~LIST_VOLUME;
|
listFlags &= ~LIST_VOLUME;
|
||||||
numVolumes = listVolumes(&onPresentPaths, &onPresentPathsUTF8);
|
numVolumes = listVolumes(&onPresentPaths, &onPresentPathsUTF8);
|
||||||
log_debugcpp(std::to_string(numVolumes) + "<- depth MAIN size() ->" + std::to_string(onPresentPaths.size()));
|
log_volume(std::to_string(numVolumes) + "<- depth MAIN size() ->" + std::to_string(onPresentPaths.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Listar UNA VEZ directorios
|
//Listar UNA VEZ directorios
|
||||||
|
|
@ -555,9 +580,9 @@ int windowRendering(wchar_t* userPath, bool* windowOpen, int windowFlags = 0){
|
||||||
if (listFlags & LIST_DIRECTORY) {
|
if (listFlags & LIST_DIRECTORY) {
|
||||||
listFlags &= ~LIST_DIRECTORY;
|
listFlags &= ~LIST_DIRECTORY;
|
||||||
chosenPath[0] = '\0';
|
chosenPath[0] = '\0';
|
||||||
log_debugcpp("ADECUADO LISTAR DIRECTORIOS");
|
log_directory("ADECUADO LISTAR DIRECTORIOS");
|
||||||
if(!retrieveCurrentDirectory(currentPath)) {
|
if(!retrieveCurrentDirectory(currentPath)) {
|
||||||
log_debugcpp("NO HABIA DIRECTORIO GetCurrentPath()");
|
log_directory("NO HABIA DIRECTORIO GetCurrentPath()");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
@ -567,7 +592,7 @@ int windowRendering(wchar_t* userPath, bool* windowOpen, int windowFlags = 0){
|
||||||
//std::cout << numFiles;
|
//std::cout << numFiles;
|
||||||
if (numFiles < 0) {
|
if (numFiles < 0) {
|
||||||
long directoryErrorCode;
|
long directoryErrorCode;
|
||||||
log_debugcpp("FALLO LA FUNCION, VALOR NEGATIVO " + std::to_string(numFiles));
|
log_directory("FALLO LA FUNCION, VALOR NEGATIVO " + std::to_string(numFiles));
|
||||||
if (numFiles == DIRECTORY_ERROR_ACCESSING_CONTENT) directoryErrorCode = getLastSystemError();
|
if (numFiles == DIRECTORY_ERROR_ACCESSING_CONTENT) directoryErrorCode = getLastSystemError();
|
||||||
showError = true;
|
showError = true;
|
||||||
switch(directoryErrorCode) {
|
switch(directoryErrorCode) {
|
||||||
|
|
@ -627,14 +652,14 @@ int windowRendering(wchar_t* userPath, bool* windowOpen, int windowFlags = 0){
|
||||||
WideCharToMultiByte(CP_UTF8, NULL, addrBarVal, -1, addrBarValUTF8,
|
WideCharToMultiByte(CP_UTF8, NULL, addrBarVal, -1, addrBarValUTF8,
|
||||||
4 * MAX_PATH, NULL, NULL);
|
4 * MAX_PATH, NULL, NULL);
|
||||||
if(ImGui::InputText("##addrbar", addrBarValUTF8, IM_ARRAYSIZE(addrBarValUTF8), ImGuiInputTextFlags_EnterReturnsTrue )){
|
if(ImGui::InputText("##addrbar", addrBarValUTF8, IM_ARRAYSIZE(addrBarValUTF8), ImGuiInputTextFlags_EnterReturnsTrue )){
|
||||||
log_debugcpp(currentPath <<" ADDRBAR INTENTO");
|
log_directory(currentPath <<" ADDRBAR INTENTO");
|
||||||
MultiByteToWideChar(CP_UTF8, NULL, addrBarValUTF8, -1, addrBarVal, 2 * MAX_PATH);
|
MultiByteToWideChar(CP_UTF8, NULL, addrBarValUTF8, -1, addrBarVal, 2 * MAX_PATH);
|
||||||
listFlags = handleFolderAccessResult(listFlags, addrBarVal, &showError, error, ErrorMessages::addrBarError, history, currentPath, addrBarVal);
|
listFlags = handleFolderAccessResult(listFlags, addrBarVal, &showError, error, ErrorMessages::addrBarError, history, currentPath, addrBarVal);
|
||||||
}
|
}
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("Enter")){
|
if(ImGui::Button("Enter")){
|
||||||
log_debugcpp(currentPath <<" ADDRBAR INTENTO");
|
log_directory(currentPath <<" ADDRBAR INTENTO");
|
||||||
listFlags = handleFolderAccessResult(listFlags, addrBarVal, &showError, error, ErrorMessages::addrBarError,
|
listFlags = handleFolderAccessResult(listFlags, addrBarVal, &showError, error, ErrorMessages::addrBarError,
|
||||||
history, currentPath, addrBarVal);
|
history, currentPath, addrBarVal);
|
||||||
}
|
}
|
||||||
|
|
@ -708,11 +733,11 @@ int windowRendering(wchar_t* userPath, bool* windowOpen, int windowFlags = 0){
|
||||||
wcscpy(chosenPath, addrBarVal);
|
wcscpy(chosenPath, addrBarVal);
|
||||||
wcscat(chosenPath, L"\\");
|
wcscat(chosenPath, L"\\");
|
||||||
wcscat(chosenPath, directoryContents.at(idx)->name);
|
wcscat(chosenPath, directoryContents.at(idx)->name);
|
||||||
log_wdebugcpp(chosenPath << L" selected");
|
log_directory(chosenPath << L" selected");
|
||||||
} else {
|
} else {
|
||||||
wcscat(addrBarVal, L"\\");
|
wcscat(addrBarVal, L"\\");
|
||||||
wcscat(addrBarVal, directoryContents.at(idx)->name);
|
wcscat(addrBarVal, directoryContents.at(idx)->name);
|
||||||
log_debugcpp("directo selected");
|
log_directory("directo selected");
|
||||||
listFlags = handleFolderAccessResult(listFlags, addrBarVal, &showError, error,
|
listFlags = handleFolderAccessResult(listFlags, addrBarVal, &showError, error,
|
||||||
ErrorMessages::tableElementError, history, currentPath, addrBarVal);
|
ErrorMessages::tableElementError, history, currentPath, addrBarVal);
|
||||||
}
|
}
|
||||||
|
|
@ -760,16 +785,16 @@ int windowRendering(wchar_t* userPath, bool* windowOpen, int windowFlags = 0){
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("Select")) {
|
if(ImGui::Button("Select")) {
|
||||||
log_wdebugcpp(chosenPath << " TRIED TO RETURN");
|
log_directory(chosenPath << " TRIED TO RETURN");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
return exitWindow(userPath, windowOpen, ExitFlags::EXIT_SELECTED);
|
return exitWindow(userPath, windowOpen, ExitFlags::SELECTED);
|
||||||
}
|
}
|
||||||
//listFlags = handleFolderAccessResult(listFlags, addrBarVal, &showError, error, ErrorMessages::addrBarError, history, currentPath, addrBarVal);
|
//listFlags = handleFolderAccessResult(listFlags, addrBarVal, &showError, error, ErrorMessages::addrBarError, history, currentPath, addrBarVal);
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
if(windowOpen) return EXIT_CONTINUE;
|
if(windowOpen) return CONTINUE;
|
||||||
else return exitWindow(userPath, windowOpen, ExitFlags::EXIT_CLOSED);
|
else return exitWindow(userPath, windowOpen, ExitFlags::CLOSED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue