comparar final string; futuro getfiletipe?
This commit is contained in:
parent
4e5f53a3e9
commit
395159763c
1 changed files with 40 additions and 27 deletions
67
main.cpp
67
main.cpp
|
|
@ -63,6 +63,28 @@ typedef struct {
|
||||||
//TODO UNICORDEO
|
//TODO UNICORDEO
|
||||||
/* FILE PICKER MOMENTO */
|
/* FILE PICKER MOMENTO */
|
||||||
|
|
||||||
|
/* PROPOSITO GENERAL */
|
||||||
|
|
||||||
|
bool compareLastChar(std::vector<std::string> *lastCharCandidates, char* string){
|
||||||
|
bool matchingExtension = false;
|
||||||
|
for (int i = 0; i < lastCharCandidates->size(); i++){
|
||||||
|
log_debugcpp(lastCharCandidates->at(i) + " <- FILTERING EXTENSION");
|
||||||
|
|
||||||
|
if(strlen(string) < lastCharCandidates->at(i).length()) continue;
|
||||||
|
char* potentialExtension = &string[strlen(string) - lastCharCandidates->at(i).length()];
|
||||||
|
|
||||||
|
log_debugcpp(potentialExtension);
|
||||||
|
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())
|
||||||
|
if(!strcmp(potentialExtension, lastCharCandidates->at(i).c_str())) {
|
||||||
|
log_debugcpp("VALID EXTENSION");
|
||||||
|
matchingExtension = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matchingExtension;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* DIRECTORIES */
|
/* DIRECTORIES */
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -77,11 +99,10 @@ bool moveDirectory(char** currentPath){
|
||||||
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<directoriesInfo*> *directoryContents){
|
||||||
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_LISTDIR_PATH_LENGTH)) return -1;
|
if (path.length() > (MAX_LISTDIR_PATH_LENGTH)) return -1;
|
||||||
|
|
@ -91,23 +112,6 @@ int listDirectory(std::string path, std::vector<directoriesInfo*> *directoryCont
|
||||||
do {
|
do {
|
||||||
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));
|
log_debugcpp("BUCLE listDirectory iteracion " + std::to_string(numFiles));
|
||||||
//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;*/
|
|
||||||
|
|
||||||
directoriesInfo* itemInfo;
|
directoriesInfo* itemInfo;
|
||||||
if (directoryContents->size() <= numFiles){
|
if (directoryContents->size() <= numFiles){
|
||||||
|
|
@ -116,7 +120,7 @@ int listDirectory(std::string path, std::vector<directoriesInfo*> *directoryCont
|
||||||
} else {
|
} else {
|
||||||
itemInfo = directoryContents->at(numFiles);
|
itemInfo = directoryContents->at(numFiles);
|
||||||
}
|
}
|
||||||
log_debugcpp("MEMORIA ASIGNADA iteracion " + std::to_string(numFiles));
|
log_debugcpp("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;
|
||||||
|
|
@ -168,11 +172,10 @@ 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
|
||||||
|
log_debugcpp(dest->at(dest->size() - 1));
|
||||||
|
log_debugcpp( " EXPLODEPATH");
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
std::cout << dest->at(dest->size() - 1);
|
|
||||||
std::cout << " EXPLODEPATH" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextOcurrence[0] == nextOcurrence[1]) return depth;
|
if (nextOcurrence[0] == nextOcurrence[1]) return depth;
|
||||||
depth++;
|
depth++;
|
||||||
|
|
@ -202,7 +205,7 @@ int listVolumes(std::vector<char*> *onPresentPaths){
|
||||||
if(GetVolumePathNamesForVolumeName(volumeName, volumePaths, volumePathsBufferSize, &volumePathLength)){
|
if(GetVolumePathNamesForVolumeName(volumeName, volumePaths, volumePathsBufferSize, &volumePathLength)){
|
||||||
|
|
||||||
if (volumePathLength == 1) { if (debug) std::cout << "Skill Issue" << std::endl; continue; }
|
if (volumePathLength == 1) { if (debug) std::cout << "Skill Issue" << std::endl; continue; }
|
||||||
if (debug) std::cout << volumeName;
|
log_debugcpp(volumeName);
|
||||||
|
|
||||||
//pathSchecker
|
//pathSchecker
|
||||||
// if (debug && volumePaths[0] == 'E') {
|
// if (debug && volumePaths[0] == 'E') {
|
||||||
|
|
@ -395,8 +398,8 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//TODO ELIMINAR RESTRICCION EXE; PRUEBITA DEL SIGNIORE
|
//TODO ELIMINAR RESTRICCION EXE; PRUEBITA DEL SIGNIORE
|
||||||
//static std::vector<std::string> restrictToExe{"exe", "DSDFD"};
|
|
||||||
numFiles = (listDirectory(std::string(currentPath), &directoryContents));//, &restrictToExe));
|
numFiles = listDirectory(std::string(currentPath), &directoryContents);
|
||||||
//std::cout << numFiles;
|
//std::cout << numFiles;
|
||||||
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));
|
||||||
|
|
@ -406,6 +409,8 @@ int main(int, char**)
|
||||||
|
|
||||||
//It's renderin' time
|
//It's renderin' time
|
||||||
static bool showHidden = false;
|
static bool showHidden = false;
|
||||||
|
static bool filterByExtension = false;
|
||||||
|
static std::vector<std::string> extensions;
|
||||||
ImGui::Text("Select a file:");
|
ImGui::Text("Select a file:");
|
||||||
|
|
||||||
//Permanentes e increiblemente utilitarios botones en Cuatro K: MOVE UP
|
//Permanentes e increiblemente utilitarios botones en Cuatro K: MOVE UP
|
||||||
|
|
@ -472,6 +477,12 @@ int main(int, char**)
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (; idx < numFiles; idx++) {
|
for (; idx < numFiles; idx++) {
|
||||||
if(directoryContents.at(idx)->isHidden && !showHidden) continue;
|
if(directoryContents.at(idx)->isHidden && !showHidden) continue;
|
||||||
|
if(filterByExtension && !directoryContents.at(idx)->isFile) {
|
||||||
|
//TODO XAPUSITA
|
||||||
|
extensions.clear();
|
||||||
|
extensions.push_back("exe");
|
||||||
|
if (!compareLastChar(&extensions, directoryContents.at(idx)->name)) continue;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
@ -516,6 +527,8 @@ int main(int, char**)
|
||||||
|
|
||||||
ImGui::Checkbox("Show hidden", &showHidden);
|
ImGui::Checkbox("Show hidden", &showHidden);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
ImGui::Checkbox("Filter by .exe", &filterByExtension);
|
||||||
|
ImGui::SameLine();
|
||||||
ImGui::Button("Select");
|
ImGui::Button("Select");
|
||||||
filepickerFailure:
|
filepickerFailure:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue