Compare commits
2 commits
4b7cc08f8e
...
c51fbcd156
| Author | SHA1 | Date | |
|---|---|---|---|
| c51fbcd156 | |||
| c52687450e |
2 changed files with 124 additions and 113 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,2 +1,4 @@
|
||||||
*.ini
|
*.ini
|
||||||
*.exe
|
*.exe
|
||||||
|
*.rdbg
|
||||||
|
*.pdb
|
||||||
237
main.cpp
237
main.cpp
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#define IMGUI_IMPLEMENTATION
|
#define IMGUI_IMPLEMENTATION
|
||||||
#define GL_SILENCE_DEPRECATION
|
#define GL_SILENCE_DEPRECATION
|
||||||
|
|
||||||
#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; \
|
||||||
|
|
@ -13,6 +14,9 @@
|
||||||
#define log_volume(str) if(debugVerbosity & DEBUG_VOLUME) log_debugcpp((str))
|
#define log_volume(str) if(debugVerbosity & DEBUG_VOLUME) log_debugcpp((str))
|
||||||
#define log_extension(str) if(debugVerbosity & DEBUG_EXTENSION) log_debugcpp((str))
|
#define log_extension(str) if(debugVerbosity & DEBUG_EXTENSION) log_debugcpp((str))
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_LISTDIR_PATH_LENGTH (MAX_PATH - 3)
|
||||||
|
|
||||||
#include "imgui/misc/single_file/imgui_single_file.h"
|
#include "imgui/misc/single_file/imgui_single_file.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -45,9 +49,16 @@ bool debug = true;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
std::vector<uint64_t> size;
|
long long size;
|
||||||
std::vector<char*> name;
|
//TODO yel spacsio NELLA MEMoria
|
||||||
} directoriesInfo, volumesInfo;
|
TCHAR name[MAX_LISTDIR_PATH_LENGTH];
|
||||||
|
SYSTEMTIME createTime;
|
||||||
|
SYSTEMTIME lastAccessTime;
|
||||||
|
SYSTEMTIME lastWriteTime;
|
||||||
|
bool isFile;
|
||||||
|
bool isHidden;
|
||||||
|
|
||||||
|
} directoriesInfo;
|
||||||
|
|
||||||
//TODO UNICORDEO
|
//TODO UNICORDEO
|
||||||
/* FILE PICKER MOMENTO */
|
/* FILE PICKER MOMENTO */
|
||||||
|
|
@ -61,27 +72,25 @@ bool retrieveCurrentDirectory(char** currentPath){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool moveDirectory(char** currentPath){
|
bool moveDirectory(char** currentPath){
|
||||||
if (debug) std::cout << *currentPath << std::endl;
|
log_debugcpp(*currentPath);
|
||||||
if(SetCurrentDirectory(*currentPath)) return true;
|
if(SetCurrentDirectory(*currentPath)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int listDirectory(std::string path, std::vector<char*> *directoryContents, std::vector<std::string> *desiredExtensions = nullptr){
|
int listDirectory(std::string path, std::vector<directoriesInfo*> *directoryContents, std::vector<std::string> *desiredExtensions = nullptr){
|
||||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
LARGE_INTEGER filesize;
|
LARGE_INTEGER filesize;
|
||||||
bool skipDueToExtension = false;
|
bool skipDueToExtension = false;
|
||||||
int numFiles = 0;
|
int numFiles = 0;
|
||||||
|
|
||||||
if (path.length() > (MAX_PATH - 3)) return -1;
|
if (path.length() > (MAX_LISTDIR_PATH_LENGTH)) return -1;
|
||||||
path = path + "\\*";
|
path = path + "\\*";
|
||||||
hFind = FindFirstFile(path.c_str(), &ffd);
|
hFind = FindFirstFile(path.c_str(), &ffd);
|
||||||
if (INVALID_HANDLE_VALUE == hFind) return -2;
|
if (INVALID_HANDLE_VALUE == hFind) return -2;
|
||||||
do {
|
do {
|
||||||
|
|
||||||
//TODO laberga k momento educativo
|
|
||||||
if(!strcmp(ffd.cFileName, ".") || !strcmp(ffd.cFileName, "..")) continue;
|
if(!strcmp(ffd.cFileName, ".") || !strcmp(ffd.cFileName, "..")) continue;
|
||||||
|
log_debugcpp("BUCLE listDirectory iteracion " + std::to_string(numFiles));
|
||||||
//Codigo pa saltarse arxibus k no estiendan
|
//Codigo pa saltarse arxibus k no estiendan
|
||||||
/*if(desiredExtensions != nullptr){
|
/*if(desiredExtensions != nullptr){
|
||||||
TCHAR* fileExtension = strrchr(ffd.cFileName, '.');
|
TCHAR* fileExtension = strrchr(ffd.cFileName, '.');
|
||||||
|
|
@ -97,37 +106,45 @@ int listDirectory(std::string path, std::vector<char*> *directoryContents, std::
|
||||||
skipDueToExtension = true;
|
skipDueToExtension = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && skipDueToExtension) continue;
|
|
||||||
|
|
||||||
//TODO multi info Struct
|
|
||||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
|
||||||
//strcat(itemPath, " <DIR>");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// filesize.QuadPart = ((ffd.nFileSizeHigh * (MAXDWORD+1)) + ffd.nFileSizeLow);
|
|
||||||
// char buf[16]; buf[0] = ' ';
|
|
||||||
// itoa(filesize.QuadPart, buf + 1 , 10 );
|
|
||||||
// strcat(itemPath, buf);
|
|
||||||
}
|
}
|
||||||
|
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && skipDueToExtension) continue;*/
|
||||||
|
|
||||||
|
//TODO Borrar legado
|
||||||
char* itemPath;
|
// char* itemPath;
|
||||||
|
// if (directoryContents->size() <= numFiles){
|
||||||
|
// itemPath = (char*)calloc(1, MAX_PATH * sizeof(WCHAR));
|
||||||
|
// directoryContents->push_back(itemPath);
|
||||||
|
// } else {
|
||||||
|
// itemPath = directoryContents->at(numFiles);
|
||||||
|
// }
|
||||||
|
directoriesInfo* itemInfo;
|
||||||
if (directoryContents->size() <= numFiles){
|
if (directoryContents->size() <= numFiles){
|
||||||
itemPath = (char*)calloc(1, MAX_PATH * sizeof(WCHAR));
|
itemInfo = new directoriesInfo();
|
||||||
directoryContents->push_back(itemPath);
|
directoryContents->push_back(itemInfo);
|
||||||
} else {
|
} else {
|
||||||
itemPath = directoryContents->at(numFiles);
|
itemInfo = directoryContents->at(numFiles);
|
||||||
}
|
}
|
||||||
|
log_debugcpp("MEMORIA ASIGNADA iteracion " + std::to_string(numFiles));
|
||||||
|
|
||||||
|
//A registrar info, fiera
|
||||||
|
itemInfo->isFile = (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false;
|
||||||
|
itemInfo->isHidden = (ffd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? true : false;
|
||||||
|
//Tamaño
|
||||||
|
filesize.QuadPart = ((ffd.nFileSizeHigh * (MAXDWORD+1)) + ffd.nFileSizeLow);
|
||||||
|
itemInfo->size = filesize.QuadPart;
|
||||||
|
//Fechitssss
|
||||||
|
FileTimeToSystemTime(&ffd.ftCreationTime, &itemInfo->createTime);
|
||||||
|
FileTimeToSystemTime(&ffd.ftLastAccessTime, &itemInfo->lastAccessTime);
|
||||||
|
FileTimeToSystemTime(&ffd.ftLastWriteTime, &itemInfo->lastWriteTime);
|
||||||
|
//Nombre de la cosita
|
||||||
uint64_t idx = 0;
|
uint64_t idx = 0;
|
||||||
do {
|
do {
|
||||||
itemPath[idx] = ffd.cFileName[idx];
|
itemInfo->name[idx] = ffd.cFileName[idx];
|
||||||
idx++;
|
idx++;
|
||||||
} while (ffd.cFileName[idx]);
|
} while (ffd.cFileName[idx]);
|
||||||
|
itemInfo->name[idx] = '\0';
|
||||||
|
log_debugcpp("INFORMACION ALMACENADA iteracion " + std::to_string(numFiles));
|
||||||
|
|
||||||
numFiles++;
|
numFiles++;
|
||||||
} while (FindNextFile(hFind, &ffd) != 0);
|
} while (FindNextFile(hFind, &ffd) != 0);
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
|
|
@ -215,17 +232,16 @@ int listVolumes(std::vector<char*> *onPresentPaths){
|
||||||
}
|
}
|
||||||
//std::cout << volumePaths << std::endl;
|
//std::cout << volumePaths << std::endl;
|
||||||
|
|
||||||
if (debug) std::cout << std::to_string(volumePathLength) + " " ;
|
log_debugcpp(std::to_string(volumePathLength) + "<- VOLUME PATH LENGTH");
|
||||||
if (debug) std::cout << "THE END" << std::endl;
|
log_debugcpp("THE END");
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
if (debug) std::cout << "no volumes found wtf" << std::endl;
|
log_debugcpp("no volumes found wtf");
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
||||||
if (debug) std::cout << std::to_string(onPresentPaths->size()) + " JUST BEFORE MAIN" << std::endl;
|
|
||||||
FindVolumeClose(hFind);
|
FindVolumeClose(hFind);
|
||||||
return numVolumes;
|
return numVolumes;
|
||||||
}
|
}
|
||||||
|
|
@ -352,8 +368,8 @@ int main(int, char**)
|
||||||
|
|
||||||
static bool isListVolumesAdequate = true;
|
static bool isListVolumesAdequate = true;
|
||||||
static bool isListDirectoriesAdequate = true;
|
static bool isListDirectoriesAdequate = true;
|
||||||
//Listar UNA VEZ volumenes
|
|
||||||
|
|
||||||
|
//Listar UNA VEZ volumenes
|
||||||
static int numVolumes;
|
static int numVolumes;
|
||||||
static std::vector<char*> onPresentPaths;
|
static std::vector<char*> onPresentPaths;
|
||||||
|
|
||||||
|
|
@ -361,7 +377,7 @@ int main(int, char**)
|
||||||
isListVolumesAdequate = false;
|
isListVolumesAdequate = false;
|
||||||
//std::cout << isListVolumesAdequate << std::endl;
|
//std::cout << isListVolumesAdequate << std::endl;
|
||||||
numVolumes = listVolumes(&onPresentPaths);
|
numVolumes = listVolumes(&onPresentPaths);
|
||||||
if (debug) std::cout << std::to_string(numVolumes) + "<- depth MAIN size() ->" + std::to_string(onPresentPaths.size()) << std::endl;
|
log_debugcpp(std::to_string(numVolumes) + "<- depth MAIN size() ->" + std::to_string(onPresentPaths.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -370,103 +386,96 @@ int main(int, char**)
|
||||||
static char currentPath[MAX_PATH];
|
static char currentPath[MAX_PATH];
|
||||||
static char* currentPathPtr = ¤tPath[0];
|
static char* currentPathPtr = ¤tPath[0];
|
||||||
|
|
||||||
static int currentItemIdx = -1;
|
//static int currentItemIdx = -1;
|
||||||
//TODO David momento
|
//static std::vector<char*> directoryContents;
|
||||||
static std::vector<char*> displayContents;
|
static std::vector<directoriesInfo*> directoryContents;
|
||||||
std::vector<char*> directoryContents;
|
|
||||||
static int numFiles = 0;
|
static int numFiles = 0;
|
||||||
|
|
||||||
if (debug) ImGui::Text("%s primir", currentPath);
|
ImGui::Text("%s PRE DIRECTORY TREATMENTO", currentPath);
|
||||||
|
|
||||||
if(isListDirectoriesAdequate) {
|
if(isListDirectoriesAdequate) {
|
||||||
log_debugcpp("renderiso");
|
log_debugcpp("ADECUADO LISTAR DIRECTORIOS");
|
||||||
isListDirectoriesAdequate = false;
|
isListDirectoriesAdequate = false;
|
||||||
if(!retrieveCurrentDirectory(¤tPathPtr)) {
|
if(!retrieveCurrentDirectory(¤tPathPtr)) {
|
||||||
if (debug) std::cout << "pencaste";
|
log_debugcpp("NO HABIA DIRECTORIO GetCurrentPath()");
|
||||||
goto filepickerFailure;
|
goto filepickerFailure;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//TODO ELIMINAR RESTRICCION EXE; PRUEBITA DEL SIGNIORE
|
//TODO ELIMINAR RESTRICCION EXE; PRUEBITA DEL SIGNIORE
|
||||||
static std::vector<std::string> restrictToExe{"exe", "DSDFD"};
|
//static std::vector<std::string> restrictToExe{"exe", "DSDFD"};
|
||||||
numFiles = (listDirectory(std::string(currentPath), &directoryContents));//, &restrictToExe));
|
numFiles = (listDirectory(std::string(currentPath), &directoryContents));//, &restrictToExe));
|
||||||
//std::cout << numFiles;
|
//std::cout << numFiles;
|
||||||
if (numFiles < 0) {
|
if (numFiles < 0) {
|
||||||
ImGui::Text("Path not valid");
|
//ImGui::Text("Path not valid");
|
||||||
if (debug) std::cout << "pencaste 2 el repencazo";
|
log_debugcpp("FALLO LA FUNCION, VALOR NEGATIVO");
|
||||||
goto filepickerFailure;
|
goto filepickerFailure;
|
||||||
}
|
}
|
||||||
if (numFiles == 0) {
|
|
||||||
if (debug) std::cout << std::to_string (numFiles) << "<- NUM FILES" << std::endl;
|
//displayContents = std::move(directoryContents);
|
||||||
char empty[] = "Empty";
|
//directoryContents.clear();
|
||||||
numFiles++;
|
|
||||||
directoryContents.push_back(empty);
|
|
||||||
}
|
|
||||||
displayContents = std::move(directoryContents);
|
|
||||||
directoryContents.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//It's renderin' time
|
//It's renderin' time
|
||||||
if(numFiles > 0){
|
ImGui::Text("Select a file:");
|
||||||
ImGui::Text("Select a file:");
|
if (debug) ImGui::Text("%s TEMPADDRBAR", currentPath);
|
||||||
if (debug) ImGui::Text("%s %d", currentPath, currentItemIdx);
|
|
||||||
|
//Y a que los VOLUMENES pinta2 pa100pre
|
||||||
//Y a que los VOLUMENES pinta2 pa100pre
|
//if (debug) std::cout << std::to_string(onPresentPaths.size()) + "<- numvols" << std::endl;
|
||||||
//if (debug) std::cout << std::to_string(onPresentPaths.size()) + "<- numvols" << std::endl;
|
if (numVolumes > 0) {
|
||||||
if (numVolumes > 0) {
|
for (int i = 0; i < onPresentPaths.size(); i++) {
|
||||||
for (int i = 0; i < onPresentPaths.size(); i++) {
|
if (i > 0) ImGui::SameLine();
|
||||||
if (i > 0) ImGui::SameLine();
|
// if (debug) std::cout << std::to_string(i) + "<- WE IN" << std::endl;
|
||||||
// if (debug) std::cout << std::to_string(i) + "<- WE IN" << std::endl;
|
// ImGui::PushID(i);
|
||||||
// ImGui::PushID(i);
|
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.6f));
|
||||||
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.6f));
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f));
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f));
|
if(ImGui::Button(onPresentPaths.at(i))){
|
||||||
if(ImGui::Button(onPresentPaths.at(i))){
|
moveDirectory(&onPresentPaths.at(i));
|
||||||
moveDirectory(&onPresentPaths.at(i));
|
isListDirectoriesAdequate = true;
|
||||||
isListDirectoriesAdequate = true;
|
|
||||||
}
|
|
||||||
ImGui::PopStyleColor(3);
|
|
||||||
// ImGui::PopID();
|
|
||||||
}
|
}
|
||||||
|
ImGui::PopStyleColor(3);
|
||||||
|
// ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Permanentes e increiblemente utilitarios botones en Cuatro K
|
|
||||||
//c pervirtio con unicode std::wstring s(L"←→↑↓");
|
|
||||||
static char moveUp[] = "..";
|
|
||||||
static char* moveUpPtr = &moveUp[0];
|
|
||||||
if(ImGui::Button("Move Up")){
|
|
||||||
moveDirectory(&moveUpPtr);
|
|
||||||
isListDirectoriesAdequate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//DIRECTORIOS ENCONTRADOS bien pinta2
|
|
||||||
if (ImGui::BeginListBox("fpLb", ImVec2(-FLT_MIN, 25 * ImGui::GetTextLineHeightWithSpacing()))){
|
|
||||||
for (int i = 0; i < numFiles; i++) {
|
|
||||||
|
|
||||||
const bool isSelected = (currentItemIdx == i);
|
|
||||||
if (ImGui::Selectable(displayContents.at(i), isSelected))
|
|
||||||
currentItemIdx = i;
|
|
||||||
|
|
||||||
if (isSelected) {
|
|
||||||
strcat(currentPath, "\\");
|
|
||||||
strcat(currentPath, displayContents.at(i));
|
|
||||||
moveDirectory(¤tPathPtr);
|
|
||||||
currentItemIdx = -1;
|
|
||||||
isListDirectoriesAdequate = true;
|
|
||||||
}
|
|
||||||
//ImGui::SetItemDefaultFocus();
|
|
||||||
|
|
||||||
}
|
|
||||||
ImGui::EndListBox();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ImGui::Text("cagaste");
|
|
||||||
}
|
}
|
||||||
//ImGui::TreePop();
|
|
||||||
filepickerFailure:
|
|
||||||
ImGui::End();
|
//Permanentes e increiblemente utilitarios botones en Cuatro K
|
||||||
|
//c pervirtio con unicode std::wstring s(L"←→↑↓");
|
||||||
|
static char moveUp[] = "..";
|
||||||
|
static char* moveUpPtr = &moveUp[0];
|
||||||
|
if(ImGui::Button("Move Up")){
|
||||||
|
moveDirectory(&moveUpPtr);
|
||||||
|
isListDirectoriesAdequate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//DIRECTORIOS ENCONTRADOS bien pinta2
|
||||||
|
if (ImGui::BeginListBox("fpLb", ImVec2(-FLT_MIN, 25 * ImGui::GetTextLineHeightWithSpacing()))){
|
||||||
|
int idx = 0;
|
||||||
|
for (; idx < numFiles; idx++) {
|
||||||
|
|
||||||
|
//const bool isSelected = (currentItemIdx == i);
|
||||||
|
bool isSelected = false;
|
||||||
|
if (ImGui::Selectable(directoryContents.at(idx)->name, &isSelected)){
|
||||||
|
//currentItemIdx = i;
|
||||||
|
strcat(currentPath, "\\");
|
||||||
|
strcat(currentPath, directoryContents.at(idx)->name);
|
||||||
|
moveDirectory(¤tPathPtr);
|
||||||
|
//currentItemIdx = -1;
|
||||||
|
isListDirectoriesAdequate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ImGui::SetItemDefaultFocus();
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!idx) ImGui::Text("Folder is empty");
|
||||||
|
ImGui::EndListBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
//ImGui::TreePop();
|
||||||
|
filepickerFailure:
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue