Compare commits
No commits in common. "c51fbcd156299c85803dd3248c0aad359dac26bd" and "4b7cc08f8efbff1eeaa8aac5659f3c1e9e86f140" have entirely different histories.
c51fbcd156
...
4b7cc08f8e
2 changed files with 113 additions and 124 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,4 +1,2 @@
|
||||||
*.ini
|
*.ini
|
||||||
*.exe
|
*.exe
|
||||||
*.rdbg
|
|
||||||
*.pdb
|
|
||||||
149
main.cpp
149
main.cpp
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#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; \
|
||||||
|
|
@ -14,9 +13,6 @@
|
||||||
#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>
|
||||||
|
|
@ -49,16 +45,9 @@ bool debug = true;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
long long size;
|
std::vector<uint64_t> size;
|
||||||
//TODO yel spacsio NELLA MEMoria
|
std::vector<char*> name;
|
||||||
TCHAR name[MAX_LISTDIR_PATH_LENGTH];
|
} directoriesInfo, volumesInfo;
|
||||||
SYSTEMTIME createTime;
|
|
||||||
SYSTEMTIME lastAccessTime;
|
|
||||||
SYSTEMTIME lastWriteTime;
|
|
||||||
bool isFile;
|
|
||||||
bool isHidden;
|
|
||||||
|
|
||||||
} directoriesInfo;
|
|
||||||
|
|
||||||
//TODO UNICORDEO
|
//TODO UNICORDEO
|
||||||
/* FILE PICKER MOMENTO */
|
/* FILE PICKER MOMENTO */
|
||||||
|
|
@ -72,25 +61,27 @@ bool retrieveCurrentDirectory(char** currentPath){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool moveDirectory(char** currentPath){
|
bool moveDirectory(char** currentPath){
|
||||||
log_debugcpp(*currentPath);
|
if (debug) std::cout << *currentPath << std::endl;
|
||||||
if(SetCurrentDirectory(*currentPath)) return true;
|
if(SetCurrentDirectory(*currentPath)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int listDirectory(std::string path, std::vector<directoriesInfo*> *directoryContents, std::vector<std::string> *desiredExtensions = nullptr){
|
int listDirectory(std::string path, std::vector<char*> *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_LISTDIR_PATH_LENGTH)) return -1;
|
if (path.length() > (MAX_PATH - 3)) 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, '.');
|
||||||
|
|
@ -106,44 +97,36 @@ int listDirectory(std::string path, std::vector<directoriesInfo*> *directoryCont
|
||||||
skipDueToExtension = true;
|
skipDueToExtension = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && skipDueToExtension) continue;*/
|
|
||||||
|
|
||||||
//TODO Borrar legado
|
|
||||||
// char* itemPath;
|
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && skipDueToExtension) continue;
|
||||||
// if (directoryContents->size() <= numFiles){
|
|
||||||
// itemPath = (char*)calloc(1, MAX_PATH * sizeof(WCHAR));
|
//TODO multi info Struct
|
||||||
// directoryContents->push_back(itemPath);
|
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
// } else {
|
//strcat(itemPath, " <DIR>");
|
||||||
// itemPath = directoryContents->at(numFiles);
|
|
||||||
// }
|
|
||||||
directoriesInfo* itemInfo;
|
|
||||||
if (directoryContents->size() <= numFiles){
|
|
||||||
itemInfo = new directoriesInfo();
|
|
||||||
directoryContents->push_back(itemInfo);
|
|
||||||
} else {
|
} else {
|
||||||
itemInfo = directoryContents->at(numFiles);
|
|
||||||
}
|
|
||||||
log_debugcpp("MEMORIA ASIGNADA iteracion " + std::to_string(numFiles));
|
|
||||||
|
|
||||||
//A registrar info, fiera
|
// filesize.QuadPart = ((ffd.nFileSizeHigh * (MAXDWORD+1)) + ffd.nFileSizeLow);
|
||||||
itemInfo->isFile = (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false;
|
// char buf[16]; buf[0] = ' ';
|
||||||
itemInfo->isHidden = (ffd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? true : false;
|
// itoa(filesize.QuadPart, buf + 1 , 10 );
|
||||||
//Tamaño
|
// strcat(itemPath, buf);
|
||||||
filesize.QuadPart = ((ffd.nFileSizeHigh * (MAXDWORD+1)) + ffd.nFileSizeLow);
|
}
|
||||||
itemInfo->size = filesize.QuadPart;
|
|
||||||
//Fechitssss
|
|
||||||
FileTimeToSystemTime(&ffd.ftCreationTime, &itemInfo->createTime);
|
char* itemPath;
|
||||||
FileTimeToSystemTime(&ffd.ftLastAccessTime, &itemInfo->lastAccessTime);
|
if (directoryContents->size() <= numFiles){
|
||||||
FileTimeToSystemTime(&ffd.ftLastWriteTime, &itemInfo->lastWriteTime);
|
itemPath = (char*)calloc(1, MAX_PATH * sizeof(WCHAR));
|
||||||
//Nombre de la cosita
|
directoryContents->push_back(itemPath);
|
||||||
|
} else {
|
||||||
|
itemPath = directoryContents->at(numFiles);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t idx = 0;
|
uint64_t idx = 0;
|
||||||
do {
|
do {
|
||||||
itemInfo->name[idx] = ffd.cFileName[idx];
|
itemPath[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);
|
||||||
|
|
@ -232,16 +215,17 @@ int listVolumes(std::vector<char*> *onPresentPaths){
|
||||||
}
|
}
|
||||||
//std::cout << volumePaths << std::endl;
|
//std::cout << volumePaths << std::endl;
|
||||||
|
|
||||||
log_debugcpp(std::to_string(volumePathLength) + "<- VOLUME PATH LENGTH");
|
if (debug) std::cout << std::to_string(volumePathLength) + " " ;
|
||||||
log_debugcpp("THE END");
|
if (debug) std::cout << "THE END" << std::endl;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
log_debugcpp("no volumes found wtf");
|
if (debug) std::cout << "no volumes found wtf" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
@ -368,8 +352,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;
|
||||||
|
|
||||||
|
|
@ -377,7 +361,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);
|
||||||
log_debugcpp(std::to_string(numVolumes) + "<- depth MAIN size() ->" + std::to_string(onPresentPaths.size()));
|
if (debug) std::cout << std::to_string(numVolumes) + "<- depth MAIN size() ->" + std::to_string(onPresentPaths.size()) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -386,38 +370,45 @@ 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;
|
||||||
//static std::vector<char*> directoryContents;
|
//TODO David momento
|
||||||
static std::vector<directoriesInfo*> directoryContents;
|
static std::vector<char*> displayContents;
|
||||||
|
std::vector<char*> directoryContents;
|
||||||
static int numFiles = 0;
|
static int numFiles = 0;
|
||||||
|
|
||||||
ImGui::Text("%s PRE DIRECTORY TREATMENTO", currentPath);
|
if (debug) ImGui::Text("%s primir", currentPath);
|
||||||
|
|
||||||
if(isListDirectoriesAdequate) {
|
if(isListDirectoriesAdequate) {
|
||||||
log_debugcpp("ADECUADO LISTAR DIRECTORIOS");
|
log_debugcpp("renderiso");
|
||||||
isListDirectoriesAdequate = false;
|
isListDirectoriesAdequate = false;
|
||||||
if(!retrieveCurrentDirectory(¤tPathPtr)) {
|
if(!retrieveCurrentDirectory(¤tPathPtr)) {
|
||||||
log_debugcpp("NO HABIA DIRECTORIO GetCurrentPath()");
|
if (debug) std::cout << "pencaste";
|
||||||
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");
|
||||||
log_debugcpp("FALLO LA FUNCION, VALOR NEGATIVO");
|
if (debug) std::cout << "pencaste 2 el repencazo";
|
||||||
goto filepickerFailure;
|
goto filepickerFailure;
|
||||||
}
|
}
|
||||||
|
if (numFiles == 0) {
|
||||||
//displayContents = std::move(directoryContents);
|
if (debug) std::cout << std::to_string (numFiles) << "<- NUM FILES" << std::endl;
|
||||||
//directoryContents.clear();
|
char empty[] = "Empty";
|
||||||
|
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;
|
||||||
|
|
@ -451,27 +442,27 @@ int main(int, char**)
|
||||||
|
|
||||||
//DIRECTORIOS ENCONTRADOS bien pinta2
|
//DIRECTORIOS ENCONTRADOS bien pinta2
|
||||||
if (ImGui::BeginListBox("fpLb", ImVec2(-FLT_MIN, 25 * ImGui::GetTextLineHeightWithSpacing()))){
|
if (ImGui::BeginListBox("fpLb", ImVec2(-FLT_MIN, 25 * ImGui::GetTextLineHeightWithSpacing()))){
|
||||||
int idx = 0;
|
for (int i = 0; i < numFiles; i++) {
|
||||||
for (; idx < numFiles; idx++) {
|
|
||||||
|
|
||||||
//const bool isSelected = (currentItemIdx == i);
|
const bool isSelected = (currentItemIdx == i);
|
||||||
bool isSelected = false;
|
if (ImGui::Selectable(displayContents.at(i), isSelected))
|
||||||
if (ImGui::Selectable(directoryContents.at(idx)->name, &isSelected)){
|
currentItemIdx = i;
|
||||||
//currentItemIdx = i;
|
|
||||||
|
if (isSelected) {
|
||||||
strcat(currentPath, "\\");
|
strcat(currentPath, "\\");
|
||||||
strcat(currentPath, directoryContents.at(idx)->name);
|
strcat(currentPath, displayContents.at(i));
|
||||||
moveDirectory(¤tPathPtr);
|
moveDirectory(¤tPathPtr);
|
||||||
//currentItemIdx = -1;
|
currentItemIdx = -1;
|
||||||
isListDirectoriesAdequate = true;
|
isListDirectoriesAdequate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ImGui::SetItemDefaultFocus();
|
//ImGui::SetItemDefaultFocus();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!idx) ImGui::Text("Folder is empty");
|
|
||||||
ImGui::EndListBox();
|
ImGui::EndListBox();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ImGui::Text("cagaste");
|
||||||
|
}
|
||||||
//ImGui::TreePop();
|
//ImGui::TreePop();
|
||||||
filepickerFailure:
|
filepickerFailure:
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue