in src/wffile.c [1412:1664]
BOOL WFDoUncompress(
HWND hDlg,
LPTSTR DirectorySpec,
LPTSTR FileSpec)
{
LPTSTR DirectorySpecEnd;
HANDLE FileHandle;
USHORT State;
ULONG Length;
HANDLE FindHandle;
WIN32_FIND_DATA FindData;
int MBRet;
//
// If the file spec is null, then clear the compression bit for
// the directory spec and get out.
//
lstrcpy(szGlobalDir, DirectorySpec);
DisplayUncompressProgress(PROGRESS_UPD_DIRECTORY);
if (lstrlen(FileSpec) == 0)
{
DoUncompressRetryCreate:
if (!OpenFileForCompress(&FileHandle, DirectorySpec))
{
goto DoUncompressError;
}
DoUncompressRetryDevIo:
State = 0;
if (!DeviceIoControl( FileHandle,
FSCTL_SET_COMPRESSION,
&State,
sizeof(USHORT),
NULL,
0,
&Length,
FALSE ))
{
DoUncompressError:
if (!bIgnoreAllErrors)
{
MBRet = CompressErrMessageBox( hDlg,
DirectorySpec,
&FileHandle );
if (MBRet == WF_RETRY_CREATE)
{
goto DoUncompressRetryCreate;
}
else if (MBRet == WF_RETRY_DEVIO)
{
goto DoUncompressRetryDevIo;
}
else if (MBRet == IDABORT)
{
//
// Return error.
// File handle closed by CompressErrMessageBox.
//
return (FALSE);
}
//
// Else (MBRet == IDIGNORE)
// Continue on as if the error did not occur.
//
}
}
if (INVALID_HANDLE_VALUE != FileHandle)
{
CloseHandle(FileHandle);
FileHandle = INVALID_HANDLE_VALUE;
}
TotalDirectoryCount++;
TotalFileCount++;
DisplayUncompressProgress(PROGRESS_UPD_DIRCNT);
DisplayUncompressProgress(PROGRESS_UPD_FILECNT);
ChangeFileSystem(FSC_ATTRIBUTES, DirectorySpec, NULL);
return (TRUE);
}
//
// Get a pointer to the end of the directory spec, so that we can
// keep appending names to the end of it.
//
DirectorySpecEnd = DirectorySpec + lstrlen(DirectorySpec);
TotalDirectoryCount++;
DisplayUncompressProgress(PROGRESS_UPD_DIRCNT);
//
// For every file in the directory that matches the file spec,
// open the file and uncompress it.
//
// Setup the template for findfirst/findnext.
//
lstrcpy(DirectorySpecEnd, FileSpec);
if ((FindHandle = FindFirstFile(DirectorySpec, &FindData)) != INVALID_HANDLE_VALUE)
{
do
{
//
// Make sure the user hasn't hit cancel.
//
if (bShowProgress && !hDlgProgress)
{
break;
}
//
// Skip over the . and .. entries.
//
if ( !lstrcmp(FindData.cFileName, SZ_DOT) ||
!lstrcmp(FindData.cFileName, SZ_DOTDOT) )
{
continue;
}
else
{
//
// Append the found file to the directory spec and
// open the file.
//
lstrcpy(DirectorySpecEnd, FindData.cFileName);
if (!(GetFileAttributes(DirectorySpec) & ATTR_COMPRESSED))
{
//
// Already uncompressed, so get the next file.
//
continue;
}
UncompressFileRetryCreate:
if (!OpenFileForCompress(&FileHandle, DirectorySpec))
{
goto UncompressFileError;
}
UncompressFileRetryDevIo:
//
// Uncompress the file.
//
if (!UncompressFile(FileHandle, &FindData))
{
UncompressFileError:
if (!bIgnoreAllErrors)
{
MBRet = CompressErrMessageBox( hDlg,
DirectorySpec,
&FileHandle );
if (MBRet == WF_RETRY_CREATE)
{
goto UncompressFileRetryCreate;
}
else if (MBRet == WF_RETRY_DEVIO)
{
goto UncompressFileRetryDevIo;
}
else if (MBRet == IDABORT)
{
//
// Return error.
// File handle closed by CompressErrMessageBox.
//
FindClose(FindHandle);
return (FALSE);
}
//
// Else (MBRet == IDIGNORE)
// Continue on as if the error did not occur.
//
}
}
if (INVALID_HANDLE_VALUE != FileHandle)
{
//
// Close the file and get the next file.
//
CloseHandle(FileHandle);
FileHandle = INVALID_HANDLE_VALUE;
}
}
} while (FindNextFile(FindHandle, &FindData));
FindClose(FindHandle);
ChangeFileSystem(FSC_ATTRIBUTES, DirectorySpec, NULL);
}
//
// If we are to do subdirectores, then look for every subdirectory
// and recursively call ourselves to list the subdirectory.
//
if (DoSubdirectories && hDlgProgress)
{
//
// Setup findfirst/findnext to search the entire directory.
//
lstrcpy(DirectorySpecEnd, SZ_STAR);
if ((FindHandle = FindFirstFile(DirectorySpec, &FindData)) != INVALID_HANDLE_VALUE)
{
do
{
//
// Skip over the . and .. entries, otherwise recurse.
//
if ( !lstrcmp(FindData.cFileName, SZ_DOT) ||
!lstrcmp(FindData.cFileName, SZ_DOTDOT) )
{
continue;
}
else
{
//
// If the entry is for a directory, then tack
// on the subdirectory name to the directory spec
// and recurse.
//
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
lstrcpy(DirectorySpecEnd, FindData.cFileName);
lstrcat(DirectorySpecEnd, SZ_BACKSLASH);
if (!WFDoUncompress(hDlg, DirectorySpec, FileSpec))
{
FindClose(FindHandle);
return (FALSE);
}
}
}
} while (FindNextFile(FindHandle, &FindData));
FindClose(FindHandle);
}
}
return (TRUE);
}