W MoveUp pero random bug al entrar en carpeta
This commit is contained in:
parent
571bb45b27
commit
02c777f968
1 changed files with 54 additions and 18 deletions
72
main.cpp
72
main.cpp
|
|
@ -47,10 +47,11 @@ bool moveDirectory(char** currentPath){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int listDirectory(std::string path, std::vector<char*> *directoryContents){
|
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;
|
||||||
int numFiles = 0;
|
int numFiles = 0;
|
||||||
|
|
||||||
if (path.length() > (MAX_PATH - 3)) return -1;
|
if (path.length() > (MAX_PATH - 3)) return -1;
|
||||||
|
|
@ -58,6 +59,42 @@ int listDirectory(std::string path, std::vector<char*> *directoryContents){
|
||||||
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;
|
||||||
|
|
||||||
|
//Codigo pa saltarse arxibus k no estiendan
|
||||||
|
/*if(desiredExtensions != nullptr){
|
||||||
|
TCHAR* fileExtension = strrchr(ffd.cFileName, '.');
|
||||||
|
if (debug && fileExtension != NULL) { std::cout << fileExtension; std::cout << " <- FILTERING EXTENSION" << std::endl; }
|
||||||
|
std::cout << ffd.cFileName << std::endl;
|
||||||
|
|
||||||
|
//TODO tabien no???
|
||||||
|
if (fileExtension == NULL) continue;
|
||||||
|
|
||||||
|
for (int i = 0; i < desiredExtensions->size(); i++) {
|
||||||
|
if (debug) { std::cout << std::to_string(strcmp(desiredExtensions->at(i).c_str(), fileExtension)) << std::endl; }
|
||||||
|
if (strcmp(desiredExtensions->at(i).c_str(), fileExtension)){
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char* itemPath;
|
char* itemPath;
|
||||||
if (directoryContents->size() <= numFiles){
|
if (directoryContents->size() <= numFiles){
|
||||||
itemPath = (char*)calloc(1, MAX_PATH * sizeof(WCHAR));
|
itemPath = (char*)calloc(1, MAX_PATH * sizeof(WCHAR));
|
||||||
|
|
@ -65,21 +102,12 @@ int listDirectory(std::string path, std::vector<char*> *directoryContents){
|
||||||
} else {
|
} else {
|
||||||
itemPath = directoryContents->at(numFiles);
|
itemPath = directoryContents->at(numFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t idx = 0;
|
uint64_t idx = 0;
|
||||||
do {
|
do {
|
||||||
itemPath[idx] = ffd.cFileName[idx];
|
itemPath[idx] = ffd.cFileName[idx];
|
||||||
idx++;
|
idx++;
|
||||||
} while (ffd.cFileName[idx]);
|
} while (ffd.cFileName[idx]);
|
||||||
//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);
|
|
||||||
}
|
|
||||||
|
|
||||||
numFiles++;
|
numFiles++;
|
||||||
} while (FindNextFile(hFind, &ffd) != 0);
|
} while (FindNextFile(hFind, &ffd) != 0);
|
||||||
|
|
@ -89,7 +117,6 @@ int listDirectory(std::string path, std::vector<char*> *directoryContents){
|
||||||
|
|
||||||
/* VOLUMES */
|
/* VOLUMES */
|
||||||
|
|
||||||
|
|
||||||
//new char*[CharCount * sizeof(WCHAR)
|
//new char*[CharCount * sizeof(WCHAR)
|
||||||
/*idea, si quisiera que empezase en punto X del string
|
/*idea, si quisiera que empezase en punto X del string
|
||||||
coger el param opcional y crear un puntero a la posicion X del array para empezar desde ahi
|
coger el param opcional y crear un puntero a la posicion X del array para empezar desde ahi
|
||||||
|
|
@ -97,7 +124,6 @@ int listDirectory(std::string path, std::vector<char*> *directoryContents){
|
||||||
char separator, std::vector<char*> *dest, , int startingFrom = 0);
|
char separator, std::vector<char*> *dest, , int startingFrom = 0);
|
||||||
if (nextOcurrence == NULL) return 0;
|
if (nextOcurrence == NULL) return 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int explodePaths(TCHAR* volumePaths, int volumePathsBufferSize, char separator, std::vector<char*> *dest, int depth = 1){
|
int explodePaths(TCHAR* volumePaths, int volumePathsBufferSize, char separator, std::vector<char*> *dest, int depth = 1){
|
||||||
//Por alguna razon esta puta mierda que dice acabar con 2 NULL acaba con 3; de locos.
|
//Por alguna razon esta puta mierda que dice acabar con 2 NULL acaba con 3; de locos.
|
||||||
//https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumepathnamesforvolumenamew
|
//https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumepathnamesforvolumenamew
|
||||||
|
|
@ -176,7 +202,7 @@ int listVolumes(std::vector<char*> *onPresentPaths){
|
||||||
if (debug) std::cout << "THE END" << std::endl;
|
if (debug) std::cout << "THE END" << std::endl;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
if (debug) std::cout << "cagaste" << std::endl;
|
if (debug) std::cout << "no volumes found wtf" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO necesario? di CAMBIAR 4 A NUL
|
//TODO necesario? di CAMBIAR 4 A NUL
|
||||||
|
|
@ -191,7 +217,6 @@ int listVolumes(std::vector<char*> *onPresentPaths){
|
||||||
/* FIN FILE PICKER MOMENTO */
|
/* FIN FILE PICKER MOMENTO */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Setup window
|
// Setup window
|
||||||
|
|
@ -345,7 +370,9 @@ int main(int, char**)
|
||||||
goto filepickerFailure;
|
goto filepickerFailure;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
numFiles = (listDirectory(std::string(currentPath), &directoryContents));
|
//TODO ELIMINAR RESTRICCION EXE; PRUEBITA DEL SIGNIORE
|
||||||
|
static std::vector<std::string> restrictToExe = { "exe" };
|
||||||
|
numFiles = (listDirectory(std::string(currentPath), &directoryContents));//, &restrictToExe));
|
||||||
//std::cout << numFiles;
|
//std::cout << numFiles;
|
||||||
if (numFiles < 0) {
|
if (numFiles < 0) {
|
||||||
if (debug) std::cout << "pencaste 2 el repencazo";
|
if (debug) std::cout << "pencaste 2 el repencazo";
|
||||||
|
|
@ -361,10 +388,11 @@ int main(int, char**)
|
||||||
|
|
||||||
//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;
|
||||||
|
//TODO dabid aiuda
|
||||||
// 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));
|
||||||
|
|
@ -374,10 +402,18 @@ int main(int, char**)
|
||||||
isListDirectoriesAdequate = true;
|
isListDirectoriesAdequate = true;
|
||||||
}
|
}
|
||||||
ImGui::PopStyleColor(3);
|
ImGui::PopStyleColor(3);
|
||||||
|
|
||||||
// ImGui::PopID();
|
// ImGui::PopID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Permanentes e increiblemente utilitarios botones en Cuatro K
|
||||||
|
//c pervirtio con unicode std::wstring s(L"←→↑↓");
|
||||||
|
//TODO TREMENDA MANDING DICK
|
||||||
|
static char moveUp[2] = {'.', '.'};
|
||||||
|
static char* moveUpPtr = &moveUp[0];
|
||||||
|
if(ImGui::Button("Move Up")){
|
||||||
|
moveDirectory(&moveUpPtr);
|
||||||
|
isListDirectoriesAdequate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//DIRECTORIOS ENCONTRADOS bien pinta2
|
//DIRECTORIOS ENCONTRADOS bien pinta2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue