⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intrface.cpp

📁 完整的解压zip文件的源码。包含密码功能
💻 CPP
📖 第 1 页 / 共 4 页
字号:
      struct tm *ptmCRT = localtime(&ut);      // Convert the "tm" struct to a FILETIME.      SYSTEMTIME stCRT;      ZeroMemory(&stCRT, sizeof(stCRT));      stCRT.wYear   = ptmCRT->tm_year + 1900;      stCRT.wMonth  = ptmCRT->tm_mon + 1;      stCRT.wDay    = ptmCRT->tm_mday;      stCRT.wHour   = ptmCRT->tm_hour;      stCRT.wMinute = ptmCRT->tm_min;      stCRT.wSecond = ptmCRT->tm_sec;      SystemTimeToFileTime(&stCRT, &ftCRT);      // Get the Win32 result - result is a FILETIME.      if (FileTimeToLocalFileTime(pft, &ftWin32)) {         // Subtract the difference from our current filetime.         *(DWORDLONG*)pft -= *(DWORDLONG*)&ftWin32 - *(DWORDLONG*)&ftCRT;      }   }}//******************************************************************************int GetFileTimes(Uz_Globs *pG, FILETIME *pftCreated, FILETIME *pftAccessed,                 FILETIME *pftModified){   // We need to check to see if this file system is limited.  This includes   // FAT, VFAT, and HPFS.  It does not include NTFS and CEFS.  The limited   // file systems can not support dates < 1980 and they store file local times   // for files as opposed to UTC times.   BOOL fOldFileSystem = IsOldFileSystem(pG->filename);#ifdef USE_EF_UT_TIME  // Always true for WinCE build#ifdef IZ_CHECK_TZ   if (pG->extra_field && pG->tz_is_valid) {#else   if (pG->extra_field) {#endif      // Structure for Unix style actime, modtime, creatime      iztimes z_utime;      // Get any date/time we can.  This can return 0 to 3 unix time fields.      unsigned eb_izux_flg = ef_scan_for_izux(pG->extra_field,                                              pG->lrec.extra_field_length, 0,                                              pG->lrec.last_mod_file_date,                                              &z_utime, NULL);      // We require at least a modified time.      if (eb_izux_flg & EB_UT_FL_MTIME) {         // We know we have a modified time, so get it first.         utimeToFileTime(z_utime.mtime, pftModified, fOldFileSystem);         // Get the accessed time if we have one.         if (eb_izux_flg & EB_UT_FL_ATIME) {            utimeToFileTime(z_utime.atime, pftAccessed, fOldFileSystem);         }         // Get the created time if we have one.         if (eb_izux_flg & EB_UT_FL_CTIME) {            utimeToFileTime(z_utime.ctime, pftCreated, fOldFileSystem);         }         // Return our flags.         return (int)eb_izux_flg;      }   }#endif // USE_EF_UT_TIME   // If all else fails, we can resort to using the DOS date and time data.   time_t ux_modtime = dos_to_unix_time(G.lrec.last_mod_file_date,                                        G.lrec.last_mod_file_time);   utimeToFileTime(ux_modtime, pftModified, fOldFileSystem);   *pftAccessed = *pftModified;   return (EB_UT_FL_MTIME | EB_UT_FL_ATIME);}//******************************************************************************void close_outfile(Uz_Globs *pG) {   // Get the 3 time stamps for the file.   FILETIME ftCreated, ftAccessed, ftModified;   int timeFlags = GetFileTimes(pG, &ftCreated, &ftAccessed, &ftModified);   TCHAR szFile[_MAX_PATH];   mbstowcs(szFile, pG->filename, countof(szFile));#ifdef _WIN32_WCE   // 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().   HANDLE hFile = (HANDLE)pG->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(pG->outfile);   HANDLE hFile = CreateFile(szFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,                             OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);#endif   // Set the file's date and time.   if (hFile != INVALID_HANDLE_VALUE) {      // Make sure we retrieved some valid time stamp(s)      if (timeFlags) {         // Set the various date and time fields.         if (!SetFileTime(hFile,                 (timeFlags & EB_UT_FL_CTIME) ? &ftCreated  : NULL,                 (timeFlags & EB_UT_FL_ATIME) ? &ftAccessed : NULL,                 (timeFlags & EB_UT_FL_MTIME) ? &ftModified : NULL))         {            DebugOut(TEXT("SetFileTime() failed [%u]"), GetLastError());         }      } else {         DebugOut(TEXT("GetFileTimes() failed"));      }      // Close out file.      CloseHandle(hFile);   } else {      DebugOut(TEXT("CreateFile() failed [%u]"), GetLastError());   }   // If the file was successfully written, then set the attributes.   if (!pG->disk_full && !g_pExtractInfo->fAbort) {      if (!SetFileAttributes(szFile, G.pInfo->file_attr & 0x7F)) {         DebugOut(TEXT("SetFileAttributes() failed [%u]"), GetLastError());      }   }   // Clear outfile so we know it is closed.   pG->outfile = 0;   return;}//******************************************************************************// Called by PROCESS.Cchar* do_wild(Uz_Globs *pG, char *wildspec) {   // This is a very slimmed down version of do_wild() taken from WIN32.C.   // Since we don't support wildcards, we basically just return the wildspec   // passed in as the filename.   // First call - must initialize everything.   if (!pG->notfirstcall) {      pG->notfirstcall = TRUE;      return strcpy(pG->matchname, wildspec);   }   // Last time through - reset for new wildspec.   pG->notfirstcall = FALSE;   return (char*)NULL;}//******************************************************************************// Called from EXTRACT.C//// returns:  1 - (on APPEND_NAME) truncated filename//           2 - path doesn't exist, not allowed to create//           3 - path doesn't exist, tried to create and failed; or//               path exists and is not a directory, but is supposed to be//           4 - path is too long//          10 - can't allocate memory for filename buffers//// IZ_VOL_LABEL   - Path was a volume label, skip it.// IZ_CREATED_DIR - Created a directory.//int mapname(Uz_Globs *pG, int renamed) {   // mapname() is a great place to reset all our status counters for the next   // file to be processed since it is called for every zip file member before   // any work is done with that member.   SetCurrentFile(pG);   // If Volume Label, skip the "extraction" quietly   if (pG->pInfo->vollabel) {      return IZ_VOL_LABEL;   }   CHAR szBuffer[countof(pG->filename)] = "", *pIn, *pOut, *pLastSemi = NULL;   // Initialize file path buffer with our "extract to" path.   strcpy(szBuffer, g_szExtractToDirectory);   pOut = szBuffer + strlen(szBuffer);   // Point pIn to beginning of our internal pathname.   // If we are junking paths, then locate the file portion of the path.   pIn = (pG->UzO.jflag) ? (CHAR*)GetFileFromPath(pG->filename) : pG->filename;   // Begin main loop through characters in filename.   for ( ; *pIn; pIn++) {      // Make sure we don't overflow our output buffer.      if (pOut >= (szBuffer + countof(szBuffer) - 2)) {         Info(slide, 1, ((char*)slide, "path too long: %s\n", pG->filename));         return 4;      }      // Examine the next character in our input buffer.      switch (*pIn) {         // Check for a directory wack.         case '/':         case '\\':            *pOut = '\0';            if (!SmartCreateDirectory(pG, szBuffer)) {               Info(slide, 1, ((char*)slide, "failure extracting: %s\n",                    pG->filename));               return 3;            }            *(pOut++) = '\\';            pLastSemi = NULL;  // Leave any directory semi-colons alone            break;         // Check for illegal characters and replace with underscore.         case ':':         case '*':         case '?':         case '"':         case '<':         case '>':         case '|':            *(pOut++) = '_';            break;         // Check for start of VMS version.         case ';':            pLastSemi = pOut;  // Make note as to where we are.            *(pOut++) = *pIn;  // Leave the semi-colon alone for now.            break;         default:            // Allow European characters and spaces in filenames.            *(pOut++) = ((*pIn >= 0x20) ? *pIn : '_');      }   }   // Done with output buffer, terminate it.   *pOut = '\0';   // Remove any VMS version numbers if found (appended ";###").   if (pLastSemi) {      // Walk over all digits following the semi-colon.      for (pOut = pLastSemi + 1; (*pOut >= '0') && (*pOut <= '9'); pOut++) {      }      // If we reached the end, then nuke the semi-colon and digits.      if (!*pOut) {         *pLastSemi = '\0';      }   }   // Copy the mapped name back to the internal path buffer   strcpy(pG->filename, szBuffer);   // Fill in the mapped name buffer if the original caller requested us to.   if (g_pExtractInfo->szMappedPath) {      strcpy(g_pExtractInfo->szMappedPath, szBuffer);   }   // If it is a directory, then display the "creating" status text.   if ((pOut > szBuffer) && (pOut[-1] == TEXT('\\'))) {      Info(slide, 0, ((char *)slide, "creating: %s\n", pG->filename));      return IZ_CREATED_DIR;   }   return PK_OK;}//******************************************************************************// Called from EXTRACT.Cint test_NT(Uz_Globs *pG, uch *eb, unsigned eb_size) {   // This function is called when an NT security descriptor is found in the   // extra field.  We have nothing to do, so we just return success.   return PK_OK;}//******************************************************************************// Called from PROCESS.Cint checkdir(Uz_Globs *pG, char *pathcomp, int flag) {   // This function is only called by free_G_buffers() from PROCESS.C with the   // flag set to END.  We have nothing to do, so we just return success.   return PK_OK;}//******************************************************************************// Called from EXTRACT.C and LIST.Cint match(char *string, char *pattern, int ignore_case) {   // match() for the other ports compares a file in the Zip file with some   // command line file pattern.  In our case, we always pass in exact matches,   // so we can simply do a string compare to see if we have a match.   return (strcmp(string, pattern) == 0);}//******************************************************************************// Called from PROCESS.Cint iswild(char *pattern) {   // Our file patterns never contain wild characters.  They are always exact   // matches of file names in our Zip file.   return FALSE;}//******************************************************************************//***** Functions to correct time stamp bugs on old file systems.//******************************************************************************//******************************************************************************// Borrowed/Modified from win32.cBOOL IsOldFileSystem(char *szPath) {#ifdef _WIN32_WCE   char szRoot[10];   // Get the first nine characters of the path.   strncpy(szRoot, szPath, 9);   szRoot[9] = '\0';   // 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}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -