Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/wince/intrface.cpp view on Meta::CPAN
// Convert to uppercase to help with compare.
_strupr(szRoot);
// PC Cards are mounted off the root in a directory called "\PC Cards".
// PC Cards are FAT, no CEOS. We need to check if the file is being
// extracted to the PC card.
return !strcmp(szRoot, "\\PC CARD\\");
#else
char szRoot[_MAX_PATH] = "\0\0\0", szFS[64];
// Check to see if our path contains a drive letter.
if (isalpha(szPath[0]) && (szPath[1] == ':') && (szPath[2] == '\\')) {
// If so, then just copy the drive letter, colon, and wack to our root path.
strncpy(szRoot, szPath, 3);
} else {
// Expand the path so we can get a drive letter.
GetFullPathNameA(szPath, sizeof(szRoot), szRoot, NULL);
// Make sure we actually got a drive letter back in our root path buffer..
if (!isalpha(szRoot[0]) || (szRoot[1] != ':') || (szRoot[2] != '\\')) {
// When in doubt, return TRUE.
return TRUE;
}
}
// NULL terminate after the wack to ensure we have just the root path.
szRoot[3] = '\0';
// Get the file system type string.
GetVolumeInformationA(szRoot, NULL, 0, NULL, NULL, NULL, szFS, sizeof(szFS));
// Ensure that the file system type string is uppercase.
_strupr(szFS);
// Return true for (V)FAT and (OS/2) HPFS format.
return !strncmp(szFS, "FAT", 3) ||
!strncmp(szFS, "VFAT", 4) ||
!strncmp(szFS, "HPFS", 4);
#endif // _WIN32_WCE
}
//******************************************************************************
int SetFileSize(FILE *file, zusz_t filesize)
{
#if (defined(_WIN32_WCE) || defined(__RSXNT__))
// For native Windows CE, it is not known whether the API supports
// presetting a file's size.
// RSXNT environment lacks a translation function from C file pointer
// to Win32-API file handle.
// So, simply do nothing.
return 0;
#else /* !(_WIN32_WCE || __RSXNT__) */
/* not yet verified, if that really creates an unfragmented file
rommel@ars.de
*/
HANDLE os_fh;
#ifdef Z_UINT8_DEFINED
LARGE_INTEGER fsbuf;
#endif
/* Win9x supports FAT file system, only; presetting file size does
not help to prevent fragmentation. */
if ((long)GetVersion() < 0) return 0;
/* Win32-API calls require access to the Win32 file handle.
The interface function used to retrieve the Win32 handle for
a file opened by the C rtl is non-standard and may not be
available for every Win32 compiler environment.
(see also win32/win32.c of the Zip distribution)
*/
os_fh = (HANDLE)_get_osfhandle(fileno(file));
/* move file pointer behind the last byte of the expected file size */
#ifdef Z_UINT8_DEFINED
fsbuf.QuadPart = filesize;
if ((SetFilePointer(os_fh, fsbuf.LowPart, &fsbuf.HighPart, FILE_BEGIN)
== 0xFFFFFFFF) && GetLastError() != NO_ERROR)
#else
if (SetFilePointer(os_fh, filesize, 0, FILE_BEGIN) == 0xFFFFFFFF)
#endif
return -1;
/* extend/truncate file to the current position */
if (SetEndOfFile(os_fh) == 0)
return -1;
/* move file position pointer back to the start of the file! */
return (SetFilePointer(os_fh, 0, 0, FILE_BEGIN) == 0xFFFFFFFF) ? -1 : 0;
#endif /* ?(_WIN32_WCE || __RSXNT__) */
} /* end function SetFileSize() */
//******************************************************************************
void close_outfile(__GPRO)
{
HANDLE hFile;
TCHAR szFile[_MAX_PATH];
MBSTOTSTR(szFile, G.filename, countof(szFile));
/* skip restoring time stamps on user's request */
if (uO.D_flag <= 1) {
// Get the 3 time stamps for the file.
FILETIME ftCreated, ftAccessed, ftModified;
int timeFlags = GetFileTimes(__G__ &ftCreated, &ftAccessed, &ftModified);
#if (defined(_WIN32_WCE) && (_WIN32_WCE < 211))
// Cast the outfile to a HANDLE (since that is really what it is), and
// flush the file. We need to flush, because any unsaved data that is
// written to the file during CloseHandle() will step on the work done
// by SetFileTime().
hFile = (HANDLE)G.outfile;
FlushFileBuffers(hFile);
#else
// Close the file and then re-open it using the Win32 CreateFile() call.
// SetFileTime() requires a Win32 file HANDLE created with GENERIC_WRITE
// access.
fclose(G.outfile);
hFile = CreateFile(szFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif
( run in 1.358 second using v1.01-cache-2.11-cpan-b16cb0d3907 )