@@ -493,99 +493,6 @@ FileState Placeholders::GetPlaceholderInfo(const std::wstring &directoryPath)
493493 return fileState;
494494}
495495
496- std::vector<std::wstring> Placeholders::GetPlaceholderWithStatePending (const std::wstring &directoryPath)
497- {
498- std::vector<std::wstring> resultPaths;
499-
500- try
501- {
502- for (const auto &entry : std::filesystem::directory_iterator (directoryPath, std::filesystem::directory_options::skip_permission_denied))
503- {
504- const auto &path = entry.path ().wstring ();
505-
506- if (entry.is_directory ())
507- {
508- FileState folderState = Placeholders::GetPlaceholderInfo (path);
509-
510- if (folderState.syncstate == SyncState::Undefined || folderState.syncstate == SyncState::NotInSync)
511- {
512- std::vector<std::wstring> subfolderPaths = GetPlaceholderWithStatePending (path);
513- resultPaths.insert (resultPaths.end (), subfolderPaths.begin (), subfolderPaths.end ());
514- }
515- }
516- else if (entry.is_regular_file ())
517- {
518- FileState placeholderState = Placeholders::GetPlaceholderInfo (path);
519-
520- bool isFileValidForSync = (placeholderState.syncstate == SyncState::Undefined || placeholderState.syncstate == SyncState::NotInSync);
521- if (isFileValidForSync && IsFileValidForSync (path))
522- {
523- resultPaths.push_back (path);
524- }
525- }
526- }
527- }
528- catch (const std::exception &e)
529- {
530- wprintf (L" [GetPlaceholderWithStatePending] Error: %s\n " , e.what ());
531- }
532-
533- return resultPaths;
534- }
535- bool Placeholders::IsFileValidForSync (const std::wstring &filePath)
536- {
537- // Obtener un handle al archivo
538- HANDLE fileHandle = CreateFileW (
539- filePath.c_str (),
540- FILE_READ_ATTRIBUTES,
541- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
542- nullptr ,
543- OPEN_EXISTING,
544- FILE_ATTRIBUTE_NORMAL,
545- nullptr );
546-
547- if (fileHandle == INVALID_HANDLE_VALUE)
548- {
549- // No se pudo abrir el archivo
550- return false ;
551- }
552-
553- // Verificar si el archivo está vacío
554- LARGE_INTEGER fileSize;
555- if (!GetFileSizeEx (fileHandle, &fileSize))
556- {
557- CloseHandle (fileHandle);
558- return false ;
559- }
560-
561- if (fileSize.QuadPart == 0 )
562- {
563- CloseHandle (fileHandle);
564- return false ;
565- }
566-
567- LARGE_INTEGER maxFileSize;
568- maxFileSize.QuadPart = 40LL * 1024 * 1024 * 1024 ; // 20GB
569-
570- if (fileSize.QuadPart > maxFileSize.QuadPart )
571- {
572- CloseHandle (fileHandle);
573- return false ;
574- }
575-
576- // // Verificar la extensión del archivo
577- if (std::filesystem::path (filePath).extension ().empty ())
578- {
579- CloseHandle (fileHandle);
580- return false ;
581- }
582-
583- // Cerrar el handle del archivo
584- CloseHandle (fileHandle);
585-
586- return true ;
587- }
588-
589496void Placeholders::ForceShellRefresh (const std::wstring &path)
590497{
591498 SHChangeNotify (SHCNE_UPDATEDIR, SHCNF_PATH, path.c_str (), nullptr );
0 commit comments