Beispiel #1
0
int __cdecl main(int argc, char **argv)
{
    WORD EarlyDosDate = 0x21;         /* Jan, 1st, 1980 */
    WORD RecentDosDate = 0x14CF;      /* Dec 15th, 2000 */
    WORD DosTime = 0x55AF;            /* 10:45:30       */
    WORD SecondDosTime = 0xBF7D;      /* 23:59:58 */
    
    FILETIME FirstResultTime;
    FILETIME SecondResultTime;
    
    ULONG64 FullFirstTime;
    ULONG64 FullSecondTime;
    
    if (0 != PAL_Initialize(argc,argv))
    {
        return FAIL;
    }
    
    /* Convert two DosDateTimes to FileTimes, ensure that each call returns
       non-zero
    */
    if(DosDateTimeToFileTime(EarlyDosDate, DosTime, &FirstResultTime) == 0)
    {
        Fail("ERROR: DosTimeToFileTime should have returned non-0 to indicate "
             "success.  GetLastError() returned %d.",GetLastError());
    }
    
    if(DosDateTimeToFileTime(RecentDosDate, 
                             SecondDosTime, &SecondResultTime) == 0)
    {
        Fail("ERROR: DosTimeToFileTime should have returned non-0 to indicate "
             "success.  GetLastError() returned %d.",GetLastError());
    }

    /* Move the FILETIME structures into a ULONG value which we can 
       work with
    */
    FullFirstTime = ((((ULONG64)FirstResultTime.dwHighDateTime)<<32) | 
                    ((ULONG64)FirstResultTime.dwLowDateTime));
    
    FullSecondTime = ((((ULONG64)SecondResultTime.dwHighDateTime)<<32) | 
                      ((ULONG64)SecondResultTime.dwLowDateTime));
    
    /* 
       The magic number below was calculated under win32 and is assumed
       to be correct.  That's the value between the two dates above.  
       Check to ensure this is always true.
    */
    
    if((FullSecondTime-FullFirstTime) != UI64(3299228680000000))
    {
        Fail("ERROR: The two dates should have been "
             "3299228680000000 nanseconds apart, but the result "
             "returned was %I64d.\n",FullSecondTime-FullFirstTime);
    }

    PAL_Terminate();
    return PASS;
}
Beispiel #2
0
unsigned _RTL_FUNC _dos_setftime(int fd, unsigned date, unsigned time)
{
    FILETIME timex,timet ;
    DosDateTimeToFileTime(date,time,&timex) ;
    LocalFileTimeToFileTime(&timex,&timet);
    return (!SetFileTime((HANDLE)fd,0,0,&timet));
}
Beispiel #3
0
void __FromDOSDT( unsigned short d, unsigned short t, FILETIME *NT_stamp )
{
    FILETIME local_ft;

    DosDateTimeToFileTime( d, t, &local_ft );
    LocalFileTimeToFileTime( &local_ft, NT_stamp );
}
Beispiel #4
0
int __stdcall RarArchive::pGetArchiveItem (
		ArchiveItemInfo *pItem
		)
{
	RARHeaderDataEx *fileHeader = (RARHeaderDataEx *)malloc (sizeof(RARHeaderDataEx));

	int nResult = m_pModule->m_pfnReadHeaderEx (m_hArchive, fileHeader);

	if ( !nResult )
	{
		memset (pItem, 0, sizeof (PluginPanelItem));

		strcpy ((char*)pItem->pi.FindData.cFileName, fileHeader->FileName);

		pItem->pi.FindData.dwFileAttributes = (BYTE)(fileHeader->FileAttr >> 16); //бред!

		if ( (fileHeader->Flags & 0x04) == 0x04 )
			pItem->dwFlags |= AIF_CRYPTED;

		FILETIME lFileTime;

		DosDateTimeToFileTime (HIWORD(fileHeader->FileTime), LOWORD(fileHeader->FileTime), &lFileTime);
		LocalFileTimeToFileTime (&lFileTime, &pItem->pi.FindData.ftLastWriteTime);

		pItem->pi.FindData.nFileSizeHigh = fileHeader->UnpSizeHigh;
		pItem->pi.FindData.nFileSizeLow = fileHeader->UnpSize;

		m_pModule->m_pfnProcessFile (m_hArchive, RAR_SKIP, NULL, NULL);

		free(fileHeader);

		return E_SUCCESS;
	}
Beispiel #5
0
static void utime2ftime(struct timeval *tv,FILETIME *ftime)
{	int year,mon,day,hour,min,sec;
	struct tm *tm;
	WORD ddate,dtime;
	struct tm tm0;
	time_t tsec;

	tsec = tv->tv_sec;
	tm = gmtime(&tsec);
	/*
	tm = gmtime(&tv->tv_sec);
	*/
	if( tm == 0 ){
		memset(&tm0,0,sizeof(tm0));
		tm = &tm0;
	}

	year = tm->tm_year + 1900 - 1980;
	mon  = tm->tm_mon  +  1;
	day  = tm->tm_mday;
	hour = tm->tm_hour;
	min  = tm->tm_min;
	sec  = tm->tm_sec / 2;
	ddate = (year <<  9) | (mon << 5) | day;
	dtime = (hour << 11) | (min << 5) | sec;
	DosDateTimeToFileTime(ddate,dtime,ftime);
}
BOOL My_DosDateTimeToFileTime()
{
	WORD wFatDate=NULL;
	WORD wFatTime=NULL;
	LPFILETIME lpFileTime=NULL;
	BOOL returnVal_Real = NULL;
	BOOL returnVal_Intercepted = NULL;

	DWORD error_Real = 0;
	DWORD error_Intercepted = 0;
	disableInterception();
	returnVal_Real = DosDateTimeToFileTime (wFatDate,wFatTime,lpFileTime);
	error_Real = GetLastError();
	enableInterception();
	returnVal_Intercepted = DosDateTimeToFileTime (wFatDate,wFatTime,lpFileTime);
	error_Intercepted = GetLastError();
	return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
Beispiel #7
0
// @pymethod <o PyTime>|pywintypes|DosDateTimeToTime|Converts an MS-DOS Date/Time to a standard Time object.
static PyObject *PyWin_DosDateTimeToTime(PyObject *self, PyObject *args)
{
	WORD wFatDate, wFatTime;
	if (!PyArg_ParseTuple(args, "hh", (WORD *)&wFatDate, (WORD *)&wFatTime))
		return NULL;
	FILETIME fd;
	if (!DosDateTimeToFileTime(wFatDate, wFatTime, &fd))
		return PyWin_SetAPIError("DosDateTimeToFileTime");
	return PyWinObject_FromFILETIME(fd);
}
Beispiel #8
0
//returns 0 if no error
int SetFileDateTime(int filehandle, FILETIMESTRUCT *ftstruct)
{
	FILETIME ft;
	int retval;

	DosDateTimeToFileTime(ftstruct->date, ftstruct->time, &ft);
	retval = SetFileTime((HANDLE)filehandle, NULL, NULL, &ft);	
	if (retval) return 0;
	else return 1;
}
Beispiel #9
0
FILETIME ZipFile::GetFileTime(size_t fileindex)
{
    FILETIME ft = { -1, -1 };
    if (uf && fileindex < fileinfo.Count()) {
        FILETIME ftLocal;
        DWORD dosDate = fileinfo.At(fileindex).dosDate;
        DosDateTimeToFileTime(HIWORD(dosDate), LOWORD(dosDate), &ftLocal);
        LocalFileTimeToFileTime(&ftLocal, &ft);
    }
    return ft;
}
Beispiel #10
0
static void test_conversions(void)
{
    FILETIME ft;
    SYSTEMTIME st;

    memset(&ft,0,sizeof ft);

    SetLastError(0xdeadbeef);
    SETUP_EARLY(st)
    ok (!SystemTimeToFileTime(&st, &ft), "Conversion succeeded EARLY\n");
    ok (GetLastError() == ERROR_INVALID_PARAMETER ||
        GetLastError() == 0xdeadbeef, /* win9x */
        "EARLY should be INVALID\n");

    SETUP_ZEROTIME(st)
    ok (SystemTimeToFileTime(&st, &ft), "Conversion failed ZERO_TIME\n");
    ok( (!((ft.dwHighDateTime != 0) || (ft.dwLowDateTime != 0))),
        "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
        ft.dwLowDateTime, ft.dwHighDateTime, 0, 0);


    SETUP_ATIME(st)
    ok (SystemTimeToFileTime(&st,&ft), "Conversion Failed ATIME\n");
    ok( (!((ft.dwHighDateTime != ATIME_HI) || (ft.dwLowDateTime!=ATIME_LOW))),
        "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
        ft.dwLowDateTime, ft.dwHighDateTime, ATIME_LOW, ATIME_HI);


    SETUP_2002(st)
    ok (SystemTimeToFileTime(&st, &ft), "Conversion failed 2002\n");

    ok( (!((ft.dwHighDateTime != MAYDAY_2002_HI) ||
         (ft.dwLowDateTime!=MAYDAY_2002_LO))),
        "Wrong time for 2002 %08x %08x (correct %08x %08x)\n", ft.dwLowDateTime,
        ft.dwHighDateTime, MAYDAY_2002_LO, MAYDAY_2002_HI);


    SETUP_1980(st)
    ok((SystemTimeToFileTime(&st, &ft)), "Conversion failed 1980\n");

    ok( (!((ft.dwHighDateTime!=NEWYEAR_1980_HI) ||
        (ft.dwLowDateTime!=NEWYEAR_1980_LO))) ,
        "Wrong time for 1980 %08x %08x (correct %08x %08x)\n", ft.dwLowDateTime,
         ft.dwHighDateTime, NEWYEAR_1980_LO,NEWYEAR_1980_HI  );

    ok(DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft),
        "DosDateTimeToFileTime() failed\n");

    ok( (!((ft.dwHighDateTime!=NEWYEAR_1980_HI) ||
         (ft.dwLowDateTime!=NEWYEAR_1980_LO))),
        "Wrong time DosDateTimeToFileTime %08x %08x (correct %08x %08x)\n",
        ft.dwHighDateTime, ft.dwLowDateTime, NEWYEAR_1980_HI, NEWYEAR_1980_LO);

}
Beispiel #11
0
int __cdecl main(int argc, char **argv)
{
    WORD UpperDosDate = 0x739F;       /* Dec 31st, 2037 */
    WORD LowerDosDate = 0x21;         /* Jan, 1st, 1980 */
    WORD UpperDosTime = 0xBF7D;       /* 23:59:58 */
    WORD LowerDosTime = 0x0;          /* 0:00:00 */
    
    FILETIME ResultTime;

    if (0 != PAL_Initialize(argc,argv))
    {
        return FAIL;
    }
    
    /* 
       Convert a DosDateTime using the highest possible date and time.
    */
    if(DosDateTimeToFileTime(UpperDosDate, UpperDosTime, &ResultTime) == 0)
    {
        Fail("ERROR: DosDateTimeToFileTime failed when attempting to "
             "convert the highest possible date and time.  GetLastError() "
             "returned %d.\n",GetLastError());
    }

    /* 
       Convert a DosDateTime using the lowest possible date and time.
    */
    if(DosDateTimeToFileTime(LowerDosDate, LowerDosTime, &ResultTime) == 0)
    {
        Fail("ERROR: DosDateTimeToFileTime failed when attempting to "
             "convert the lowest possible date and time.  GetLastError() "
             "returned %d.\n",GetLastError());
    }

    
    PAL_Terminate();
    return PASS;
}
Beispiel #12
0
/// File data
/// ---------
// Updates [file] with the data from [s].
static int zip_file_info_set(zip_file_info_t *file, zip_file_shared_t *s)
{
	if(!file || !s) {
		return -1;
	}
	file->compression = s->compression;
	file->size_compressed = s->size_compressed;
	file->size_uncompressed = s->size_uncompressed;
	if(file->mtime.dwLowDateTime == 0) {
		DosDateTimeToFileTime(s->mdate, s->mtime, &file->mtime);
		file->ctime = file->mtime;
		file->atime = file->mtime;
	}
	return 0;
}
Beispiel #13
0
static UINT WINAPI ExtCabCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
{
    FILE_IN_CABINET_INFO_W *pInfo;
    FILEPATHS_W *pFilePaths;

    switch(Notification)
    {
        case SPFILENOTIFY_FILEINCABINET:
            pInfo = (FILE_IN_CABINET_INFO_W*)Param1;
            if(show_content)
            {
                FILETIME ft;
                SYSTEMTIME st;
                CHAR date[12], time[12], buf[2 * MAX_PATH];
                int count;
                DWORD dummy;

                /* DosDate and DosTime already represented at local time */
                DosDateTimeToFileTime(pInfo->DosDate, pInfo->DosTime, &ft);
                FileTimeToSystemTime(&ft, &st);
                GetDateFormatA(0, 0, &st, "MM'-'dd'-'yyyy", date, sizeof date);
                GetTimeFormatA(0, 0, &st, "HH':'mm':'ss", time, sizeof time);
                count = wsprintfA(buf, "%s %s %c%c%c%c %15u %S\n", date, time,
                        pInfo->DosAttribs & FILE_ATTRIBUTE_ARCHIVE  ? 'A' : '-',
                        pInfo->DosAttribs & FILE_ATTRIBUTE_HIDDEN   ? 'H' : '-',
                        pInfo->DosAttribs & FILE_ATTRIBUTE_READONLY ? 'R' : '-',
                        pInfo->DosAttribs & FILE_ATTRIBUTE_SYSTEM   ? 'S' : '-',
                        pInfo->FileSize, pInfo->NameInCabinet);
                WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buf, count, &dummy, NULL);
                return FILEOP_SKIP;
            }
            else
            {
                lstrcpyW(pInfo->FullTargetName, (LPCWSTR)Context);
                lstrcatW(pInfo->FullTargetName, pInfo->NameInCabinet);
                /* SetupIterateCabinet() doesn't create full path to target by itself,
                   so we should do it manually */
                create_target_directory(pInfo->FullTargetName);
                return FILEOP_DOIT;
            }
        case SPFILENOTIFY_FILEEXTRACTED:
            pFilePaths = (FILEPATHS_W*)Param1;
            WINE_TRACE("Extracted %s\n", wine_dbgstr_w(pFilePaths->Target));
            return NO_ERROR;
    }
    return NO_ERROR;
}
Beispiel #14
0
int WINAPI _export GetArcItem(struct PluginPanelItem *Item,struct ArcItemInfo *Info)
{
  struct CFFILE FileHeader;

  DWORD ReadSize;
  char *EndPos;
  FILETIME lft;

  if (FilesNumber-- == 0)
    return GETARC_EOF;
  if (!ReadFile(ArcHandle,&FileHeader,sizeof(FileHeader),&ReadSize,NULL)
      || ReadSize < 18)
    return GETARC_READERROR;

  EndPos = (char *)FileHeader.szName;
  while (EndPos - (char*)&FileHeader < (int)sizeof(FileHeader) && *EndPos)
    EndPos++;
  if (EndPos - (char*)&FileHeader >= (int)sizeof(FileHeader))
    return GETARC_BROKEN;

  SetFilePointer( ArcHandle, (LONG)((EndPos-(char*)&FileHeader+1) - ReadSize), NULL, FILE_CURRENT );

  EndPos = (char *)FileHeader.szName;
  while (*EndPos)
  {
    if (*EndPos == '/')
      *EndPos = '\\';
    EndPos++;
  }

  EndPos = (char *)FileHeader.szName;
  if (EndPos[ 0 ] == '\\' && EndPos[ 1 ] != '\\')
    EndPos++;

  CharToOem( EndPos, Item->FindData.cFileName );

  #define _A_ENCRYPTED 8
  Item->FindData.dwFileAttributes = FileHeader.attribs & (FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_DIRECTORY);
  Info->Encrypted = FileHeader.attribs & _A_ENCRYPTED;
  Item->PackSize=0;
  Item->FindData.nFileSizeLow=FileHeader.cbFile;
  DosDateTimeToFileTime(FileHeader.date,FileHeader.time,&lft);
  LocalFileTimeToFileTime(&lft,&Item->FindData.ftLastWriteTime);
  Info->UnpVer=UnpVer;
  return(GETARC_SUCCESS);
}
Beispiel #15
0
void FName::SetFileTime(long t)
{
#ifdef WIN32
    HANDLE f=CreateFile(Str,GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
    if (f==INVALID_HANDLE_VALUE) return;
    FILETIME ft;
    DosDateTimeToFileTime(HIWORD(t),LOWORD(t),&ft);
    ::SetFileTime(f,NULL,NULL,&ft);
    CloseHandle(f);
#else
    int hand;
    union Time {
        ftime ft;
        DWORD dw;
    } ft;
    ft.dw=t;
    if ((hand=open(Str,O_RDONLY))<0) return;
    setftime(hand,&ft.ft);
    close(hand);
#endif
}
Beispiel #16
0
static void test_conversions(void)
{
    FILETIME ft;
    SYSTEMTIME st;

    memset(&ft,0,sizeof ft);

    SETUP_ATIME(st)
    ok (SystemTimeToFileTime(&st,&ft), "Conversion Failed ATIME\n");
    ok( (!((ft.dwHighDateTime != ATIME_HI) || (ft.dwLowDateTime!=ATIME_LOW))),
        "Wrong time for ATIME: %08lx %08lx (correct %08x %08x)\n",
        ft.dwLowDateTime, ft.dwHighDateTime, ATIME_LOW, ATIME_HI);


    SETUP_2002(st)
    ok (SystemTimeToFileTime(&st, &ft), "Conversion failed 2002\n");

    ok( (!((ft.dwHighDateTime != MAYDAY_2002_HI) ||
         (ft.dwLowDateTime!=MAYDAY_2002_LO))),
        "Wrong time for 2002 %08lx %08lx (correct %08x %08x)\n", ft.dwLowDateTime,
        ft.dwHighDateTime, MAYDAY_2002_LO, MAYDAY_2002_HI);


    SETUP_1980(st)
    ok((SystemTimeToFileTime(&st, &ft)), "Conversion failed 1980\n");

    ok( (!((ft.dwHighDateTime!=NEWYEAR_1980_HI) ||
        (ft.dwLowDateTime!=NEWYEAR_1980_LO))) ,
        "Wrong time for 1980 %08lx %08lx (correct %08x %08x)\n", ft.dwLowDateTime,
         ft.dwHighDateTime, NEWYEAR_1980_LO,NEWYEAR_1980_HI  );

    ok(DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft),
        "DosDateTimeToFileTime() failed\n");

    ok( (!((ft.dwHighDateTime!=NEWYEAR_1980_HI) ||
         (ft.dwLowDateTime!=NEWYEAR_1980_LO))),
        "Wrong time DosDateTimeToFileTime %08lx %08lx (correct %08x %08x)\n",
        ft.dwHighDateTime, ft.dwLowDateTime, NEWYEAR_1980_HI, NEWYEAR_1980_LO);

}
Beispiel #17
0
static void test_invalid_arg(void)
{
    FILETIME ft;
    SYSTEMTIME st;


    /* Invalid argument checks */

    memset(&ft,0,sizeof ft);
    ok( DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft), /* this is 1 Jan 1980 00:00:00 */
        "DosDateTimeToFileTime() failed\n");

    ok( (ft.dwHighDateTime==NEWYEAR_1980_HI) && (ft.dwLowDateTime==NEWYEAR_1980_LO),
        "filetime for 1/1/80 00:00:00 was %08x %08x\n", ft.dwHighDateTime, ft.dwLowDateTime);

    /* now check SystemTimeToFileTime */
    memset(&ft,0,sizeof ft);


    /* try with a bad month */
    SETUP_1980(st)
    st.wMonth = 0;

    ok( !SystemTimeToFileTime(&st, &ft), "bad month\n");

    /* with a bad hour */
    SETUP_1980(st)
    st.wHour = 24;

    ok( !SystemTimeToFileTime(&st, &ft), "bad hour\n");

    /* with a bad minute */
    SETUP_1980(st)
    st.wMinute = 60;

    ok( !SystemTimeToFileTime(&st, &ft), "bad minute\n");
}
Beispiel #18
0
CString FormatDateTime32bit(const Variant& value)
{
   unsigned int uiTime = GetUnsignedIntValue(value);

   FILETIME fileTime = { 0 };
   BOOL bRet = DosDateTimeToFileTime(HIWORD(uiTime), LOWORD(uiTime), &fileTime);
   if (bRet != TRUE)
      return _T("N/A");

   SYSTEMTIME systemTime = { 0 };
   bRet = FileTimeToSystemTime(&fileTime, &systemTime);
   if (bRet != TRUE)
      return _T("N/A");

   CString cszDate;
   GetDateFormat(LOCALE_USER_DEFAULT, 0, &systemTime, _T("yyyy'-'MM'-'dd"), cszDate.GetBuffer(32), 32);
   cszDate.ReleaseBuffer();

   CString cszTime;
   GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systemTime, _T(" HH':'mm':'ss"), cszTime.GetBuffer(32), 32);
   cszTime.ReleaseBuffer();

   return cszDate + cszTime;
}
Beispiel #19
0
void extract_archive(void *hWnd)
{
    uint i;
    char arcname[MAX_PATH * 2];
    char outdir[MAX_PATH * 2];
    char outfilename[MAX_PATH * 2];
    CUnImp Imp;
    IMP_ARCHIVE_INFO iai;
    DWORD dwAttribute;
    FILETIME ctime;
    FILETIME ctime_local;
    FILETIME mtime;
    FILETIME mtime_local;
    GetModuleFileName(GetModuleHandle(NULL),arcname,MAX_PATH * 2);
    if (Imp.open_archive(arcname,&iai) == false)
    {
        MessageBox((HWND)hWnd,"自己展開書庫ではありません。","IMP Self Extract Archiver",MB_OK);
        extract_flag = false;
        _endthread();
    }
    GetDlgItemText((HWND)hWnd,IDC_OUTDIR,outdir,MAX_PATH * 2);
    if (outdir[lstrlen(outdir) - 1] != '\\')
    {
        lstrcat(outdir,"\\");
    }
    for (i = 0;i < iai.file_count;i++)
    {
        sprintf(outfilename,"%s%s",outdir,iai.ifh[i].filename);
        SetDlgItemText((HWND)hWnd,IDC_FILENAME,iai.ifh[i].filename);
        if (Imp.extract_file(iai.ifh[i].dirent,outfilename) == false)
        {
            MessageBox((HWND)hWnd,"展開に失敗しました。","IMP Self Extract Archiver",MB_OK);
            Imp.close_archive();
            free(iai.ifh);
            extract_flag = false;
            _endthread();
        }
        dwAttribute = 0;
        if (iai.ifh[i].dirent.attrib & _A_ARCH)
        {
            dwAttribute |= FILE_ATTRIBUTE_ARCHIVE;
        }
        if (iai.ifh[i].dirent.attrib & _A_HIDDEN)
        {
            dwAttribute |= FILE_ATTRIBUTE_HIDDEN;
        }
        if (iai.ifh[i].dirent.attrib & _A_RDONLY)
        {
            dwAttribute |= FILE_ATTRIBUTE_READONLY;
        }
        if (iai.ifh[i].dirent.attrib & _A_SUBDIR)
        {
            dwAttribute |= FILE_ATTRIBUTE_DIRECTORY;
        }
        if (iai.ifh[i].dirent.attrib & _A_SYSTEM)
        {
            dwAttribute |= FILE_ATTRIBUTE_SYSTEM;
        }
        SetFileAttributes(outfilename,dwAttribute);
        DosDateTimeToFileTime(iai.ifh[i].dirent.cdate,iai.ifh[i].dirent.ctime,&ctime);
        FileTimeToLocalFileTime(&ctime,&ctime_local);
        DosDateTimeToFileTime(iai.ifh[i].dirent.cdate,iai.ifh[i].dirent.ctime,&mtime);
        FileTimeToLocalFileTime(&mtime,&mtime_local);
        SetFileTimeEx(outfilename,ctime_local,mtime_local,mtime_local);
    }
    Imp.close_archive();
    free(iai.ifh);
    MessageBox((HWND)hWnd,"展開に成功しました。","IMP Self Extract Archiver",MB_OK);
    extract_flag = false;
    _endthread();
}
Beispiel #20
0
/* Fills in sig with the values from the Signature table, where name is the
 * signature to find.  Upon return, sig->File will be NULL if the record is not
 * found, and not NULL if it is found.
 * Warning: clears all fields in sig!
 * Returns ERROR_SUCCESS upon success (where not finding the record counts as
 * success), something else on error.
 */
static UINT ACTION_AppSearchGetSignature(MSIPACKAGE *package, MSISIGNATURE *sig, LPCWSTR name)
{
    static const WCHAR query[] = {
        's','e','l','e','c','t',' ','*',' ',
        'f','r','o','m',' ',
        'S','i','g','n','a','t','u','r','e',' ',
        'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e',' ','=',' ',
        '\'','%','s','\'',0};
    LPWSTR minVersion, maxVersion;
    MSIRECORD *row;
    DWORD time;

    TRACE("package %p, sig %p\n", package, sig);

    memset(sig, 0, sizeof(*sig));
    sig->Name = name;
    row = MSI_QueryGetRecord( package->db, query, name );
    if (!row)
    {
        TRACE("failed to query signature for %s\n", debugstr_w(name));
        return ERROR_SUCCESS;
    }

    /* get properties */
    sig->File = msi_dup_record_field(row,2);
    minVersion = msi_dup_record_field(row,3);
    if (minVersion)
    {
        msi_parse_version_string( minVersion, &sig->MinVersionMS, &sig->MinVersionLS );
        msi_free( minVersion );
    }
    maxVersion = msi_dup_record_field(row,4);
    if (maxVersion)
    {
        msi_parse_version_string( maxVersion, &sig->MaxVersionMS, &sig->MaxVersionLS );
        msi_free( maxVersion );
    }
    sig->MinSize = MSI_RecordGetInteger(row,5);
    if (sig->MinSize == MSI_NULL_INTEGER)
        sig->MinSize = 0;
    sig->MaxSize = MSI_RecordGetInteger(row,6);
    if (sig->MaxSize == MSI_NULL_INTEGER)
        sig->MaxSize = 0;
    sig->Languages = msi_dup_record_field(row,9);
    time = MSI_RecordGetInteger(row,7);
    if (time != MSI_NULL_INTEGER)
        DosDateTimeToFileTime(HIWORD(time), LOWORD(time), &sig->MinTime);
    time = MSI_RecordGetInteger(row,8);
    if (time != MSI_NULL_INTEGER)
        DosDateTimeToFileTime(HIWORD(time), LOWORD(time), &sig->MaxTime);

    TRACE("Found file name %s for Signature_ %s;\n",
          debugstr_w(sig->File), debugstr_w(name));
    TRACE("MinVersion is %d.%d.%d.%d\n", HIWORD(sig->MinVersionMS),
          LOWORD(sig->MinVersionMS), HIWORD(sig->MinVersionLS),
          LOWORD(sig->MinVersionLS));
    TRACE("MaxVersion is %d.%d.%d.%d\n", HIWORD(sig->MaxVersionMS),
          LOWORD(sig->MaxVersionMS), HIWORD(sig->MaxVersionLS),
          LOWORD(sig->MaxVersionLS));
    TRACE("MinSize is %d, MaxSize is %d;\n", sig->MinSize, sig->MaxSize);
    TRACE("Languages is %s\n", debugstr_w(sig->Languages));

    msiobj_release( &row->hdr );

    return ERROR_SUCCESS;
}
Beispiel #21
0
/* XXX Should better explicitely specify
 * uncomp_size and file_times instead of pfhdr!
 */
char *map_new_file (DWORD flags, char *filename,
		    char *pathname_part, int size,
		    WORD wFatDate, WORD wFatTime,
		    NOTIFYPROC notify)
{
    HANDLE hFile, hFileMapping;
    char *dst;
    FILETIME ft;

  try_again:
    if (!flags)
	flags = CREATE_NEW;
    hFile = CreateFile (filename,
			GENERIC_WRITE | GENERIC_READ,
			0, NULL,
			flags,
			FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile == INVALID_HANDLE_VALUE) {
	DWORD x = GetLastError();
	switch (x) {
	case ERROR_FILE_EXISTS:
	    if (notify && notify (CAN_OVERWRITE, filename))
	       	hFile = CreateFile (filename,
				    GENERIC_WRITE | GENERIC_READ,
				    0, NULL,
				    CREATE_ALWAYS,
				    FILE_ATTRIBUTE_NORMAL, NULL);
	    else {
		if (notify)
		    notify (FILE_OVERWRITTEN, filename);
		return NULL;
	    }
	    break;
	case ERROR_PATH_NOT_FOUND:
	    if (ensure_directory (filename, pathname_part, notify))
		goto try_again;
	    else
		return FALSE;
	    break;
	default:
	    SetLastError (x);
	    break;
	}
    }
    if (hFile == INVALID_HANDLE_VALUE) {
	if (notify)
	    notify (SYSTEM_ERROR, "CreateFile (%s)", filename);
	return NULL;
    }

    if (notify)
	notify (FILE_CREATED, filename);

    DosDateTimeToFileTime (wFatDate, wFatTime, &ft);
    SetFileTime (hFile, &ft, &ft, &ft);


    if (size == 0) {
	/* We cannot map a zero-length file (Also it makes
	   no sense */
	CloseHandle (hFile);
	return NULL;
    }

    hFileMapping = CreateFileMapping (hFile,
				      NULL, PAGE_READWRITE, 0, size, NULL);

    CloseHandle (hFile);

    if (hFileMapping == INVALID_HANDLE_VALUE) {
	if (notify)
	    notify (SYSTEM_ERROR, "CreateFileMapping (%s)", filename);
	return NULL;
    }

    dst = MapViewOfFile (hFileMapping,
			 FILE_MAP_WRITE, 0, 0, 0);

    CloseHandle (hFileMapping);

    if (!dst) {
	if (notify)
	    notify (SYSTEM_ERROR, "MapViewOfFile (%s)", filename);
	return NULL;
    }
    return dst;
}
Beispiel #22
0
static INT_PTR cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
{
    TRACE("(%d)\n", fdint);

    switch (fdint)
    {
    case fdintPARTIAL_FILE:
    {
        CabData *data = (CabData *)pfdin->pv;
        data->mi->is_continuous = FALSE;
        return 0;
    }
    case fdintNEXT_CABINET:
    {
        CabData *data = (CabData *)pfdin->pv;
        struct media_info *mi = data->mi;
        LPWSTR cab = strdupAtoW(pfdin->psz1);
        UINT rc;

        msi_free(mi->disk_prompt);
        msi_free(mi->cabinet);
        msi_free(mi->volume_label);
        mi->disk_prompt = NULL;
        mi->cabinet = NULL;
        mi->volume_label = NULL;

        mi->disk_id++;
        mi->is_continuous = TRUE;

        rc = msi_media_get_disk_info(data->package, mi);
        if (rc != ERROR_SUCCESS)
        {
            msi_free(cab);
            ERR("Failed to get next cabinet information: %d\n", rc);
            return -1;
        }

        if (lstrcmpiW(mi->cabinet, cab))
        {
            msi_free(cab);
            ERR("Continuous cabinet does not match the next cabinet in the Media table\n");
            return -1;
        }

        msi_free(cab);

        TRACE("Searching for %s\n", debugstr_w(mi->source));

        if (GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES)
            rc = msi_change_media(data->package, mi);

        if (rc != ERROR_SUCCESS)
            return -1;

        return 0;
    }
    case fdintCOPY_FILE:
    {
        CabData *data = (CabData*) pfdin->pv;
        HANDLE handle;
        LPWSTR file;
        MSIFILE *f;
        DWORD attrs;

        file = strdupAtoW(pfdin->psz1);
        f = get_loaded_file(data->package, file);
        msi_free(file);

        if (!f)
        {
            WARN("unknown file in cabinet (%s)\n",debugstr_a(pfdin->psz1));
            return 0;
        }

        if (f->state != msifs_missing && f->state != msifs_overwrite)
        {
            TRACE("Skipping extraction of %s\n",debugstr_a(pfdin->psz1));
            return 0;
        }

        msi_file_update_ui( data->package, f, szInstallFiles );

        TRACE("extracting %s\n", debugstr_w(f->TargetPath) );

        attrs = f->Attributes & (FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
        if (!attrs) attrs = FILE_ATTRIBUTE_NORMAL;

        handle = CreateFileW( f->TargetPath, GENERIC_READ | GENERIC_WRITE, 0,
                              NULL, CREATE_ALWAYS, attrs, NULL );
        if ( handle == INVALID_HANDLE_VALUE )
        {
            if ( GetFileAttributesW( f->TargetPath ) != INVALID_FILE_ATTRIBUTES )
                f->state = msifs_installed;
            else
                ERR("failed to create %s (error %d)\n",
                    debugstr_w( f->TargetPath ), GetLastError() );

            return 0;
        }

        f->state = msifs_installed;
        return (INT_PTR) handle;
    }
    case fdintCLOSE_FILE_INFO:
    {
        CabData *data = (CabData*) pfdin->pv;
        FILETIME ft;
        FILETIME ftLocal;
        HANDLE handle = (HANDLE) pfdin->hf;

        data->mi->is_continuous = FALSE;

        if (!DosDateTimeToFileTime(pfdin->date, pfdin->time, &ft))
            return -1;
        if (!LocalFileTimeToFileTime(&ft, &ftLocal))
            return -1;
        if (!SetFileTime(handle, &ftLocal, 0, &ftLocal))
            return -1;
        CloseHandle(handle);
        return 1;
    }
    default:
        return 0;
    }
}
Beispiel #23
0
int WINAPI _export GetArcItem(struct PluginPanelItem *Item,struct ArcItemInfo *Info)
{
  ARCHeader Header;
  DWORD ReadSize;
  NextPosition=SetFilePointer(ArcHandle,NextPosition,NULL,FILE_BEGIN);

  if (NextPosition==0xFFFFFFFF)
    return(GETARC_READERROR);

  if (NextPosition>FileSize)
    return(GETARC_UNEXPEOF);

  if (!ReadFile(ArcHandle,&Header,sizeof(WORD),&ReadSize,NULL))
    return(GETARC_READERROR);

  if (!ReadSize || ReadSize!=2)
    return(GETARC_EOF);

  if (Header.HeadId != 0x1A || ((Header.Type)&0x80))
    return GETARC_BROKEN;

  if(Header.Type == 0)
  {
    DWORD CurPos=SetFilePointer(ArcHandle,ReadSize+NextPosition,NULL,FILE_BEGIN);
    if(CurPos != (DWORD)-1 && CurPos < FileSize)
      ArcComment=1;
    return(GETARC_EOF);
  }

  if (!ReadFile(ArcHandle,((char*)&Header)+sizeof(WORD),sizeof(Header)-sizeof(WORD),&ReadSize,NULL))
    return(GETARC_READERROR);

  NextPosition+=sizeof(Header)+Header.CompSize;
  if(Header.Type == 1) // old style is shorter
  {
    // SetFilePointer(ArcHandle,-(sizeof(DWORD)),NULL,FILE_CURRENT); // для варианта с извлечением!
    Header.Type=2;  // convert header to new format
    Header.OrigSize=Header.CompSize;  // size is same when not packed
    NextPosition-=sizeof(DWORD);
  }

  if(OffsetComment)
  {
    SetFilePointer(ArcHandle,OffsetComment,NULL,FILE_BEGIN);
    ReadFile(ArcHandle,Info->Description,32,&ReadSize,NULL);
    OffsetComment+=32;
    Info->Comment=1;
  }

  lstrcpyn(Item->FindData.cFileName,Header.Name,sizeof(Item->FindData.cFileName));

  lstrcpyn(Item->FindData.cAlternateFileName,Header.Name,sizeof(Item->FindData.cAlternateFileName));

  Item->FindData.nFileSizeLow=Header.OrigSize;
  Item->FindData.nFileSizeHigh=0;
  Item->FindData.dwFileAttributes=FILE_ATTRIBUTE_ARCHIVE; //??
  Item->PackSize=Header.CompSize;

  Item->CRC32=(DWORD)Header.CRC16;

  FILETIME lft;
  DosDateTimeToFileTime(Header.FileDate,Header.FileTime,&lft);
  LocalFileTimeToFileTime(&lft,&Item->FindData.ftLastWriteTime);

  int Ver=6*256;
  if(Header.Type == 1)
    Ver=1*256;
  else if(Header.Type == 2)
    Ver=3*256+1;
  else if(Header.Type <= 5)
    Ver=4*256;
  else if(Header.Type == 6)
    Ver=4*256+1;
  else if(Header.Type == 7)
    Ver=4*256+6;
  else if(Header.Type <= 9)
    Ver=5*256;

  Info->UnpVer=Ver;

  return(GETARC_SUCCESS);
}
Beispiel #24
0
 /******************************************************************************
     TrackingComment:
     Get tracking comment string. This function returns TRUE if tracking comment
     exist at the given loction.
 ******************************************************************************/
 BOOL TrackingComment(PTERWND w, long line, int col, LPBYTE pMsg)
 {
     int font=GetCurCfmt(w,line,col);
     int len=0,DateLen;
     int rev;
     WORD DosDate,DosTime;
     FILETIME FileTime;
     SYSTEMTIME SysTime;
     BYTE pDateTime[MAX_WIDTH+1];

     if (True(TerFlags6&TFLAG6_NO_TRACK_MSG)) return false;

     if (HideChanges) return false;   // 20081003

     if (False(TerFont[font].InsRev) && False(TerFont[font].DelRev) && False(TerFont[font].FmtRev)) return false;     // ftc

     if (True(TerFont[font].InsRev)) {
         rev=TerFont[font].InsRev;

         // format date/time
         DosDate=HIWORD(TerFont[font].InsTime);
         DosTime=LOWORD(TerFont[font].InsTime);
         DosDateTimeToFileTime(DosDate,DosTime,&FileTime);
         FileTimeToSystemTime(&FileTime,&SysTime);
         
         GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&SysTime,NULL,pDateTime,MAX_WIDTH);
         strcat(pDateTime," ");
         DateLen=lstrlen(pDateTime);
         GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&SysTime,NULL,&(pDateTime[DateLen]),MAX_WIDTH);

         wsprintf(&(pMsg[len]),"%s%s\r\n    @ %s",MsgString[MSG_INSERTED_BY],reviewer[rev].name,pDateTime);

         len=lstrlen(pMsg);
     } 

     if (True(TerFont[font].DelRev)) {
         rev=TerFont[font].DelRev;

         // format date/time
         DosDate=HIWORD(TerFont[font].DelTime);
         DosTime=LOWORD(TerFont[font].DelTime);
         DosDateTimeToFileTime(DosDate,DosTime,&FileTime);
         FileTimeToSystemTime(&FileTime,&SysTime);
         
         GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&SysTime,NULL,pDateTime,MAX_WIDTH);
         strcat(pDateTime," ");
         DateLen=lstrlen(pDateTime);
         GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&SysTime,NULL,&(pDateTime[DateLen]),MAX_WIDTH);

         if (len>0) {                 // start on the new line
           lstrcat(pMsg,"\n");
           len=lstrlen(pMsg);
         }
          
         wsprintf(&(pMsg[len]),"%s%s\r\n    @ %s",MsgString[MSG_DELETED_BY],reviewer[rev].name,pDateTime);

         len=lstrlen(pMsg);
     } 

     if (True(TerFont[font].FmtRev)) {
         rev=TerFont[font].FmtRev;

         // format date/time
         DosDate=HIWORD(TerFont[font].FmtTime);
         DosTime=LOWORD(TerFont[font].FmtTime);
         DosDateTimeToFileTime(DosDate,DosTime,&FileTime);
         FileTimeToSystemTime(&FileTime,&SysTime);
         
         GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&SysTime,NULL,pDateTime,MAX_WIDTH);
         strcat(pDateTime," ");
         DateLen=lstrlen(pDateTime);
         GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&SysTime,NULL,&(pDateTime[DateLen]),MAX_WIDTH);

         if (len>0) {                 // start on the new line
           lstrcat(pMsg,"\n");
           len=lstrlen(pMsg);
         }
          
         wsprintf(&(pMsg[len]),"%s%s\r\n    @ %s",MsgString[MSG_FMT_BY],reviewer[rev].name,pDateTime);

         len=lstrlen(pMsg);
     } 


     return (lstrlen(pMsg)>0);
 }
Beispiel #25
0
// 展開
// [E,X] [ArchiveName] [BaseDirectory] [Path] ...
// 基準ディレクトリが指定されてない場合はカレントディレクトリに展開
int Extract(HWND hwnd,HANDLE hCmdLine,HANDLE hMessage,bool path)
{
    char *p;
    short per;
    int j;
    int k;
    int f;
    int mfc = 0;
    int length;
    int path_start;
    int update_file = 1;
    int write_skip = 0;
    int answer_yes = 0;
    int recursive = 0;
    int unjust_path = 1;
    int save_attribute = 0;
    int check_disk = 1;
    int extract_dos_name = 0;
    int show_dialog = 0;
    int check_disk_size = 0;
    int user_set = 0;
    int delete_root = 1;
    int exclusion_file_count;
    char *exclusion_file[MAX_PATH * 2];
    bool current_update_mode;
    bool check;
    uint32 i;
    char lm = '0';
    char temp[513];
    char _basedirectory[MAX_PATH * 2];
    char basedirectory[MAX_PATH * 2];
    char *filepath;
    char ap[MAX_PATH * 2];
    char arcname[MAX_PATH * 2];
    char message[4096];
    char filename[MAX_PATH * 2];
    char outfilename[MAX_PATH * 2];
    char relpath[MAX_PATH * 2];
    DWORD dwAttribute;
    char name83[MAX_PATH * 2];
    HWND wnd;
    FILETIME ctime;
    FILETIME ctime_local;
    FILETIME mtime;
    FILETIME mtime_local;
    SYSTEMTIME cf_systime;
    SYSTEMTIME tf_systime;
    UpdateInfo ui;
    struct _stat fdata;
    FILETIMEINFO tfi;
    ENUM_MEMBER_INFO64 param64;
    BOOL cs;
    BOOL retval;
    FILETIME lft;
    FILETIME cft;
    FILETIME aft;
    FILETIME mft;
    if (libarcdll_GetOtherDataCount(hCmdLine) < 2)
    {
        return ERROR_COMMAND_NAME;
    }
    libarcdll_GetSwitch(hCmdLine,NULL,"a",NULL,NULL,NULL,"%d",&save_attribute);
    libarcdll_GetSwitch(hCmdLine,NULL,"n",NULL,NULL,NULL,"%d",&show_dialog);
    libarcdll_GetSwitch(hCmdLine,NULL,"f",NULL,NULL,NULL,"%d",&check_disk);
    libarcdll_GetSwitch(hCmdLine,NULL,"jb",NULL,NULL,NULL,"%d",&check_disk_size);
    libarcdll_GetSwitch(hCmdLine,NULL,"jp",NULL,NULL,NULL,"%d",&unjust_path);
    libarcdll_GetSwitch(hCmdLine,NULL,"jo",NULL,NULL,NULL,"%c%s",&lm,temp);
    libarcdll_GetSwitch(hCmdLine,NULL,"r",NULL,NULL,NULL,"%d",&recursive);
    libarcdll_GetSwitch(hCmdLine,NULL,"m",NULL,NULL,NULL,"%d",&answer_yes);
    libarcdll_GetSwitch(hCmdLine,NULL,"s",NULL,NULL,NULL,"%d",&write_skip);
    libarcdll_GetSwitch(hCmdLine,NULL,"u",NULL,NULL,NULL,"%d",&update_file);
    libarcdll_GetSwitch(hCmdLine,NULL,"ji",NULL,NULL,NULL,"%d",&extract_dos_name);
    libarcdll_GetSwitch(hCmdLine,NULL,"jf",NULL,NULL,NULL,"%d",&delete_root);
    tfi.mode = lm - '0';
    tfi.ft.dwHighDateTime = 0;
    tfi.ft.dwLowDateTime = 0;
    libarcdll_GetOtherData(hCmdLine,0,"%s",arcname);
    libarcdll_GetOtherData(hCmdLine,1,"%s",_basedirectory);
    if (g_Imp.open_archive(arcname,&g_iai) == false)
    {
        return g_Imp.get_last_error();
    }
    if (show_dialog == 0)
    {
        wnd = (hwnd != NULL) ? hwnd : GetDesktopWindow();
        g_window = CreateDialogParam(g_hInst,MAKEINTRESOURCE(IDD_STATUS),hwnd,(DLGPROC)StatusProc,(LPARAM)wnd);
    }
    else
    {
        g_window = NULL;
    }
    if (g_window != NULL)
    {
        ShowWindow(g_window,SW_SHOWNORMAL);
        SetFocus(g_window);
        _fullpath(temp,arcname,513);
        libarcdll_AbbreviationPath(temp,ap,40,0,3);
        SetDlgItemText(g_window,IDC_ARCNAME,ap);
        libarcdll_doevents();
    }
    if (_basedirectory[lstrlen(_basedirectory) - 1] != '\\' && _basedirectory[lstrlen(_basedirectory) - 1] != '/')
    {
        GetCurrentDirectory(MAX_PATH * 2,basedirectory);
        path_start = 1;
    }
    else
    {
        lstrcpy(basedirectory,_basedirectory);
        path_start = 2;
    }
    length = lstrlen(basedirectory);
    for (f = 0;f < length;f++)
    {
        if (libarcdll_isJMS(basedirectory,f) == 0 && (basedirectory[f] == '\\' || basedirectory[f] == '/'))
        {
            basedirectory[f] = '\\';
        }
    }
    if (basedirectory[length - 1] != '\\')
    {
        lstrcat(basedirectory,"\\");
    }
    if (CUnImp::mkdir2(basedirectory) == false)
    {
        if (g_window != NULL)
        {
            DestroyWindow(g_window);
        }
        return ERROR_MAKEDIRECTORY;
    }
    for (i = 0,length = libarcdll_GetOtherDataCount(hCmdLine);i < g_iai.file_count;i++)
    {
        check = false;
        if (check_disk == 1)
        {
            if (libarcdll_CheckDiskSize(basedirectory,g_iai.ifh[i].dirent.esize) == FALSE)
            {
                goto check_end;
            }
        }
        if (check_disk_size != 0)
        {
            if (libarcdll_CheckDiskSize(basedirectory,check_disk_size) == FALSE)
            {
                goto check_end;
            }
        }
        if (save_attribute == 0 && (g_iai.ifh[i].dirent.attrib & _A_HIDDEN || g_iai.ifh[i].dirent.attrib & _A_SYSTEM))
        {
            goto check_end;
        }
        DosDateTimeToFileTime(g_iai.ifh[i].dirent.mdate,g_iai.ifh[i].dirent.mtime,&mtime);
        switch (tfi.mode)
        {
        case 0:
            break;
        case 1:
            FileTimeToSystemTime(&mtime,&cf_systime);
            FileTimeToSystemTime(&tfi.ft,&tf_systime);
            if (cf_systime.wYear != tf_systime.wYear)
            {
                goto check_end;
            }
            if (cf_systime.wMonth != tf_systime.wMonth)
            {
                goto check_end;
            }
            if (cf_systime.wMonth != tf_systime.wMonth)
            {
                goto check_end;
            }
            break;
        case 2:
            if (CompareFileTime(&tfi.ft,&mtime) > 0)
            {
                goto check_end;
            }
            break;
        case 3:
            if (CompareFileTime(&tfi.ft,&mtime) < 0)
            {
                goto check_end;
            }
            break;
        }
        if ((length - path_start) > 0)
        {
            filepath = (char*)malloc(513);
            for (j = path_start;j < length;j++)
            {
                libarcdll_GetOtherData(hCmdLine,j,"%s",filepath);
                if (recursive == 0)
                {
                    if (libarcdll_ComparisonWildcard2(filepath,g_iai.ifh[i].filename,COMPARISON_MODE_SAMEDIRECTORY) == TRUE)
                    {
                        check = true;
                    }
                }
                else
                {
                    if (libarcdll_ComparisonWildcard2(filepath,g_iai.ifh[i].filename,COMPARISON_MODE_RECURSIVE) == TRUE)
                    {
                        check = true;
                    }
                }
            }
            free(filepath);
        }
        else
        {
            if (recursive == 1)
            {
                check = true;
            }
            else if (recursive == 0 && libarcdll_GetCharCount(g_iai.ifh[i].filename,'\\') == 0)
            {
                check = true;
            }
        }
        if (check == false)
        {
            goto check_end;
        }
        if (libarcdll_IsValidFileName(g_iai.ifh[i].filename) == FALSE)
        {
            if (unjust_path == 0 || answer_yes == 1)
            {
                goto check_end;
            }
            if (MessageBox(g_window,"指定したディレクトリ以外の場所に展開されようとしています。\n展開しますか?","UnImp32.dll",MB_YESNO) == IDNO)
            {
                goto check_end;
            }
        }
        libarcdll_GetSwitch(hCmdLine,NULL,"jx",&exclusion_file_count,exclusion_file,NULL,NULL);
        for (j = 0;j < exclusion_file_count;j++)
        {
            if (libarcdll_ComparisonWildcard(exclusion_file[j],g_iai.ifh[i].filename) == TRUE)
            {
                check = false;
            }
        }
        for (j = 0;j < exclusion_file_count;j++)
        {
            free(exclusion_file[j]);
        }
        if (check == true)
        {
            lstrcpy(filename,g_iai.ifh[i].filename);
            if (path == false)
            {
                p = strrchr(g_iai.ifh[i].filename,'\\');
                if (p != NULL)
                {
                    for (k = 0;!(libarcdll_isJMS(p,k + 1) == 0 && *(p + k + 1) == '\0');k++)
                    {
                        filename[k] = *(p + k + 1);
                    }
                    filename[k] = '\0';
                }
            }
            if (delete_root == 1)
            {
                ConvertAbsPathToRelPath(filename,relpath);
            }
            else
            {
                lstrcpy(relpath,filename);
            }
            sprintf(temp,"%s%s",basedirectory,relpath);
            _fullpath(outfilename,temp,513);
            cs = FALSE;
            retval = FALSE;
            DosDateTimeToFileTime(g_iai.ifh[i].dirent.cdate,g_iai.ifh[i].dirent.ctime,&lft);
            FileTimeToLocalFileTime(&lft,&cft);
            DosDateTimeToFileTime(g_iai.ifh[i].dirent.mdate,g_iai.ifh[i].dirent.mtime,&lft);
            FileTimeToLocalFileTime(&lft,&aft);
            DosDateTimeToFileTime(g_iai.ifh[i].dirent.mdate,g_iai.ifh[i].dirent.mtime,&lft);
            FileTimeToLocalFileTime(&lft,&mft);
            {
                param64.dwStructSize = sizeof(ENUM_MEMBER_INFO64);
                param64.uCommand = UNIMP_EXTRACT_COMMAND;
                param64.llOriginalSize = g_iai.ifh[i].orgsize;
                param64.llCompressedSize = g_iai.ifh[i].compsize;
                param64.dwAttributes = GetAttributes(g_iai.ifh[i].dirent.attrib);
                param64.dwCRC = 0;
                param64.uOSType = 0;
                param64.wRatio = 0;
                param64.ftCreateTime = cft;
                param64.ftAccessTime = aft;
                param64.ftWriteTime = mft;
                lstrcpy(param64.szFileName,g_iai.ifh[i].filename);
                lstrcpy(param64.szAddFileName,outfilename);
                cs = libarcdll_SendEnumMembersProc2(&param64,&retval);
            }
            if (cs == TRUE && retval == FALSE)
            {
                check = false;
            }
            if (check == true)
            {
                lstrcpy(temp,param64.szAddFileName);
                _fullpath(outfilename,temp,513);
            }
        }
check_end:
        if (check == true)
        {
            g_nStatus = -1;
            g_iai_number = i;
            if (g_window != NULL)
            {
                libarcdll_AbbreviationPath(g_iai.ifh[i].filename,ap,40,0,3);
                SetDlgItemText(g_window,IDC_FILENAME,ap);
                libarcdll_AbbreviationPath(outfilename,ap,40,0,3);
                SetDlgItemText(g_window,IDC_OUTFILENAME,ap);
            }
            current_update_mode = true;
            if (_stat(outfilename,&fdata) == 0)
            {
                if (answer_yes == 1)
                {
                    user_set = 1;
                }
                switch (user_set)
                {
                case 0:
                    libarcdll_GetFileTime(outfilename,NULL,NULL,&ctime,TRUE);
                    switch (update_file)
                    {
                    case 0:
                        current_update_mode = true;
                        break;
                    case 1:
                        if (CompareFileTime(&mtime,&ctime) > 0)
                        {
                            current_update_mode = true;
                        }
                        break;
                    case 2:
                        if (CompareFileTime(&mtime,&ctime) < 0)
                        {
                            current_update_mode = true;
                        }
                        break;
                    case 3:
                        if (CompareFileTime(&mtime,&ctime) != 0)
                        {
                            current_update_mode = true;
                        }
                        break;
                    case 4:
                        user_set = 2;
                        current_update_mode = false;
                        break;
                    case 5:
                        lstrcpy(ui.in,relpath);
                        lstrcpy(ui.out,outfilename);
                        ui.hWnd = g_window;
                        switch (DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_UPDATE),g_window,(DLGPROC)UpdateDialogProc,(LPARAM)&ui))
                        {
                        case 1:
                            user_set = 1;
                        case 0:
                            current_update_mode = true;
                            break;
                        case 3:
                            user_set = 2;
                        case 2:
                            current_update_mode = false;
                            break;
                        }
                        break;
                    }
                    break;
                case 1:
                    current_update_mode = true;
                    break;
                case 2:
                    current_update_mode = false;
                    break;
                }
            }
            if (current_update_mode == true)
            {
                remove(outfilename);
                sprintf(message,"Extracting %s\n",g_iai.ifh[i].filename);
                libarcdll_AddMessage(hMessage,message);
                _beginthread(Extracting_Thread,0,(void*)outfilename);
                while (g_nStatus == -1)
                {
                    libarcdll_doevents();
                }
                if (g_nStatus != 0)
                {
                    remove(outfilename);
                    g_Imp.close_archive();
                    if (g_window != NULL)
                    {
                        DestroyWindow(g_window);
                    }
                    free(g_iai.ifh);
                    return g_Imp.get_last_error();
                }
                mfc++;
                if (save_attribute == 0)
                {
                    SetFileAttributes(outfilename,FILE_ATTRIBUTE_ARCHIVE);
                }
                else
                {
                    dwAttribute = GetAttributes(g_iai.ifh[i].dirent.attrib);
                    SetFileAttributes(outfilename,dwAttribute);
                }
                DosDateTimeToFileTime(g_iai.ifh[i].dirent.cdate,g_iai.ifh[i].dirent.ctime,&ctime);
                FileTimeToLocalFileTime(&ctime,&ctime_local);
                DosDateTimeToFileTime(g_iai.ifh[i].dirent.cdate,g_iai.ifh[i].dirent.ctime,&mtime);
                FileTimeToLocalFileTime(&mtime,&mtime_local);
                libarcdll_SetFileTime(outfilename,ctime_local,mtime_local,mtime_local);
                if (extract_dos_name == 1)
                {
                    GetShortPathName(outfilename,name83,MAX_PATH * 2);
                    rename(outfilename,name83);
                }
            }
            else
            {
                if (write_skip == 0)
                {
                    sprintf(message,"Skipping %s\n",g_iai.ifh[i].filename);
                    libarcdll_AddMessage(hMessage,message);
                }
            }
            if (g_window != NULL)
            {
                per = i * 100 / g_iai.file_count;
                SendDlgItemMessage(g_window,IDC_PROGRESS,PBM_SETPOS,per,0L);
            }
            libarcdll_doevents();
        }
        else
        {
            if (write_skip == 0)
            {
                sprintf(message,"Skipping %s\n",g_iai.ifh[i].filename);
                libarcdll_AddMessage(hMessage,message);
            }
        }
        if (bCancel == true)
        {
            i++;
            for (;i < g_iai.file_count;i++)
            {
                sprintf(message,"Canceled %s\n",g_iai.ifh[i].filename);
                libarcdll_AddMessage(hMessage,message);
            }
            break;
        }
    }
    g_Imp.close_archive();
    if (g_window != NULL)
    {
        DestroyWindow(g_window);
    }
    free(g_iai.ifh);
    if (bCancel == false && mfc == 0)
    {
        return ERROR_NOT_FIND_FILE;
    }
    return (bCancel == true) ? ERROR_USER_CANCEL : 0;
}
Beispiel #26
0
/******************************************************************************
 *      CoDosDateTimeToFileTime [COMPOBJ.31]
 */
BOOL16 WINAPI CoDosDateTimeToFileTime16(WORD wDosDate, WORD wDosTime, FILETIME *ft)
{
    return DosDateTimeToFileTime(wDosDate, wDosTime, ft);
}
Beispiel #27
0
bool extractCurrentFile(unzFile uf, TCHAR *path)
{
    int err = UNZ_OK;
    unz_file_info64 file_info;
    char filename[MAX_PATH];
	char buf[8192];

    err = unzGetCurrentFileInfo64(uf, &file_info, filename, sizeof(filename), buf, sizeof(buf), NULL, 0);
    if (err != UNZ_OK) return false;

	// Get Unicode file name for InfoZip style archives, otherwise assume PKZip/WinZip style
	if (file_info.size_file_extra)
	{
		char *p = buf; 
		unsigned long size = min(file_info.size_file_extra, sizeof(buf));
		while (size > 0)
		{
			unsigned short id =  *(unsigned short*)p;
			unsigned len =  *(unsigned short*)(p + 2);
			
			if (size < (len + 4)) break;

			if (id == 0x7075 && len > 5 && (len - 5) < sizeof(filename) && *(p + 4) == 1)
			{
				memcpy(filename, p + 9, len - 5);
				filename[len - 5] = 0;
				break;
			}
			size -= len + 4;
			p += len + 4;
		}
	}

	TCHAR save_file[MAX_PATH];
	TCHAR* p = mir_utf8decodeT(filename);
	if (p == NULL) p = mir_a2t(filename);
	mir_sntprintf(save_file, SIZEOF(save_file), _T("%s\\%s"), path, p);
	mir_free(p);

	for (p = save_file; *p; ++p) if (*p == '/') *p = '\\'; 

	if (file_info.external_fa & FILE_ATTRIBUTE_DIRECTORY)
		CreatePath(save_file);
	else
	{
		err = unzOpenCurrentFile(uf);
		if (err != UNZ_OK) return false;

		p = _tcsrchr(save_file, '\\'); if (p) *p = 0;
		CreatePath(save_file);
		if (p) *p = '\\';

		HANDLE hFile = CreateFile(save_file, GENERIC_WRITE, FILE_SHARE_WRITE, 0, 
			CREATE_ALWAYS, file_info.external_fa, 0);
		
		if (hFile != INVALID_HANDLE_VALUE)
		{
			for (;;)
			{
				err = unzReadCurrentFile(uf, buf, sizeof(buf));
				if (err <= 0) break;

				DWORD bytes;
				if (!WriteFile(hFile, buf, err, &bytes, FALSE))
				{
					err = UNZ_ERRNO;
					break;
				}
			}

			FILETIME ftLocal, ftCreate, ftLastAcc, ftLastWrite;
			GetFileTime(hFile, &ftCreate, &ftLastAcc, &ftLastWrite);
			DosDateTimeToFileTime(HIWORD(file_info.dosDate), LOWORD(file_info.dosDate), &ftLocal);
			LocalFileTimeToFileTime(&ftLocal, &ftLastWrite);
			SetFileTime(hFile, &ftCreate, &ftLastAcc, &ftLastWrite);

			CloseHandle(hFile);
			unzCloseCurrentFile(uf); /* don't lose the error */
		}
    }
	return true;
}
Beispiel #28
0
bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath, bool ch)
{
	unz_file_info64 file_info;
	char filename[MAX_PATH], buf[8192];

	int err = unzGetCurrentFileInfo64(uf, &file_info, filename, sizeof(filename), buf, sizeof(buf), NULL, 0);
	if (err != UNZ_OK)
		return false;

	for (char *p = strchr(filename, '/'); p; p = strchr(p+1, '/'))
		*p = '\\';

	if (ch && !db_get_b(NULL, MODNAME "Files", StrToLower(ptrA(mir_strdup(filename))), 1))
		return true;

	TCHAR tszDestFile[MAX_PATH], tszBackFile[MAX_PATH];
	TCHAR *ptszNewName = mir_utf8decodeT(filename);
	if (ptszNewName == NULL)
		ptszNewName = mir_a2t(filename);

	if (!(file_info.external_fa & FILE_ATTRIBUTE_DIRECTORY)) {
		err = unzOpenCurrentFile(uf);
		if (err != UNZ_OK)
			return false;

		if (ptszBackPath != NULL) {
			PrepareFileName(tszDestFile, SIZEOF(tszDestFile), ptszDestPath, ptszNewName);
			PrepareFileName(tszBackFile, SIZEOF(tszBackFile), ptszBackPath, ptszNewName);
			BackupFile(tszDestFile, tszBackFile);
		}

		PrepareFileName(tszDestFile, SIZEOF(tszDestFile), ptszDestPath, ptszNewName);
		SafeCreateFilePath(tszDestFile);

		TCHAR *ptszFile2unzip;
		if (hPipe == NULL) // direct mode
			ptszFile2unzip = tszDestFile;
		else {
			TCHAR tszTempPath[MAX_PATH];
			GetTempPath( SIZEOF(tszTempPath), tszTempPath);
			GetTempFileName(tszTempPath, _T("PUtemp"), GetCurrentProcessId(), tszBackFile);
			ptszFile2unzip = tszBackFile;
		}

		HANDLE hFile = CreateFile(ptszFile2unzip, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, file_info.external_fa, 0);
		if (hFile == INVALID_HANDLE_VALUE)
			return false;
			
		while (true) {
			err = unzReadCurrentFile(uf, buf, sizeof(buf));
			if (err <= 0)
				break;

			DWORD bytes;
			if (!WriteFile(hFile, buf, err, &bytes, FALSE)) {
				err = UNZ_ERRNO;
				break;
			}
		}

		FILETIME ftLocal, ftCreate, ftLastAcc, ftLastWrite;
		GetFileTime(hFile, &ftCreate, &ftLastAcc, &ftLastWrite);
		DosDateTimeToFileTime(HIWORD(file_info.dosDate), LOWORD(file_info.dosDate), &ftLocal);
		LocalFileTimeToFileTime(&ftLocal, &ftLastWrite);
		SetFileTime(hFile, &ftCreate, &ftLastAcc, &ftLastWrite);

		CloseHandle(hFile);
		unzCloseCurrentFile(uf); /* don't lose the error */

		if (hPipe)
			SafeMoveFile(ptszFile2unzip, tszDestFile);
	}
	mir_free(ptszNewName);
	return true;
}
Beispiel #29
0
int tempzip_make(HWND hwndDlg, TCHAR *fn)
{
  TCHAR buf[MAX_PATH];
  GetTempPath(MAX_PATH,buf);
  GetTempFileName(buf,_T("z2e"),GetTickCount(),tempzip_path);
  if (!CreateDirectory(tempzip_path,NULL))
  {
    GetTempPath(MAX_PATH,tempzip_path);
    _tcscat(tempzip_path,_T("\\nsi"));
    if (!CreateDirectory(tempzip_path,NULL))
    {
      tempzip_path[0]=0;
      MessageBox(hwndDlg,_T("Error creating temporary directory"),g_errcaption,MB_OK|MB_ICONSTOP);
      return 1;
    }
  }
  FILE *fp=_tfopen(fn,_T("rb"));
  if (fp)
  {
    fseek(fp,0,SEEK_END);
    g_zipfile_size=ftell(fp);
    fclose(fp);
  }
  else g_zipfile_size=0;
  unzFile f;
  f = unzOpen(fn);
  if (!f || unzGoToFirstFile(f) != UNZ_OK)
  {
    if (f) unzClose(f);
    MessageBox(hwndDlg,_T("Error opening ZIP file"),g_errcaption,MB_OK|MB_ICONSTOP);
    return 1;
  }

  int nf=0, nkb=0;
  g_extracting=1;
  do {
    char filenameA[MAX_PATH];
    unz_file_info info;

    // ZREAD uses byte size, not TCHAR length.
    unzGetCurrentFileInfo(f,&info,filenameA,sizeof(filenameA),NULL,0,NULL,0);

    // was zip created on MS-DOS/Windows?
    if ((info.version & 0xFF00) == 0)
    {
      OemToCharBuffA(filenameA, filenameA, (DWORD)strlen(filenameA));
    }

#ifdef _UNICODE
    TCHAR filename[MAX_PATH];
    if (MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filename, MAX_PATH) == 0)
    {
      if (f) unzClose(f);
      MessageBox(hwndDlg,_T("Error converting filename to Unicode"), g_errcaption, MB_OK|MB_ICONSTOP);
      return 1;
    }
#else
    char* filename = filenameA;
#endif

    if (filename[0] &&
        filename[_tcslen(filename)-1] != _T('\\') &&
        filename[_tcslen(filename)-1] != _T('/'))
    {
      TCHAR *pfn=filename;
      while (*pfn)
      {
        if (*pfn == _T('/')) *pfn=_T('\\');
        pfn++;
      }
      pfn=filename;
      if (pfn[1] == _T(':') && pfn[2] == _T('\\')) pfn+=3;
      while (*pfn == _T('\\')) pfn++;

      TCHAR out_filename[1024];
      lstrcpy(out_filename,tempzip_path);
      lstrcat(out_filename,_T("\\"));
      lstrcat(out_filename,pfn);
      if (_tcsstr(pfn,_T("\\")))
      {
        TCHAR buf[1024];
        lstrcpy(buf,out_filename);
        TCHAR *p=buf+_tcslen(buf);
        while (p > buf && *p != _T('\\')) p--;
        *p=0;
        if (buf[0]) doMKDir(buf);
      }

      if (unzOpenCurrentFile(f) == UNZ_OK)
      {
        SendDlgItemMessage(hwndDlg,IDC_ZIPINFO_FILES,LB_ADDSTRING,0,(LPARAM)pfn);
        FILE *fp;
        int l;
        fp = _tfopen(out_filename,_T("wb"));
        if (fp)
        {
          do
          {
            // Jim Park: Local buf, no need to TCHAR
            char buf[1024];
            l=unzReadCurrentFile(f,buf,sizeof(buf));
            if (l > 0)
            {
              if (fwrite(buf,1,l,fp) != (unsigned int)l)
              {
                unzClose(f);
                fclose(fp);
                MessageBox(hwndDlg,_T("Error writing output file(s)"),g_errcaption,MB_OK|MB_ICONSTOP);
                g_extracting=0;
                return 1;
              }
              nkb++;
            }
          } while (l > 0);

          fclose(fp);

          {
            // set file time
            HANDLE hf = CreateFile(out_filename, GENERIC_WRITE, 0, 0, OPEN_ALWAYS, 0, 0);
            if (hf != INVALID_HANDLE_VALUE)
            {
              FILETIME ft, lft;
              DosDateTimeToFileTime(HIWORD(info.dosDate), LOWORD(info.dosDate), &ft);
              LocalFileTimeToFileTime(&ft, &lft);
              SetFileTime(hf, 0, 0, &lft);
              CloseHandle(hf);
            }
          }
        }
        else
        {
          unzClose(f);
          MessageBox(hwndDlg,_T("Error opening output file(s)"),g_errcaption,MB_OK|MB_ICONSTOP);
          g_extracting=0;
          return 1;
        }
        nf++;
        wsprintf(buf,_T("Extracting: %d files, %dKB"),nf,nkb);
        SetDlgItemText(hwndDlg,IDC_ZIPINFO_SUMMARY,buf);
        MSG msg;
        int quit=0;
        while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
        {
          if (msg.message == WM_DESTROY && msg.hwnd == g_hwnd)
          {
            quit++;
            break;
          }
          TranslateMessage(&msg);
          DispatchMessage(&msg);
        }
        unzCloseCurrentFile(f);
        if (quit) break;
      }
      else
      {
        unzClose(f);
        MessageBox(hwndDlg,_T("Error extracting from ZIP file"),g_errcaption,MB_OK|MB_ICONSTOP);
        g_extracting=0;
        return 1;
      }
    }
  } while (unzGoToNextFile(f) == UNZ_OK);

  g_extracting=0;
  wsprintf(buf,_T("Extracted: %d files, %dKB"),nf,nkb);
  SetDlgItemText(hwndDlg,IDC_ZIPINFO_SUMMARY,buf);
  unzClose(f);
  return 0;
}
Beispiel #30
0
bool vmsArchiveRAR::Extract(LPCSTR pszArchive, LPCSTR pszOutFolder)
{
	m_errExtract = AEE_GENERIC_ERROR;

	if (m_unrar.is_Loaded () == false) {
		if (false == m_unrar.Load ("Archive\\unrar.dll"))
			return false;
	}

	HANDLE hFile = CreateFile (pszArchive, GENERIC_READ, FILE_SHARE_READ, NULL, 
		OPEN_EXISTING, 0, NULL);
	if (hFile == INVALID_HANDLE_VALUE)
		return false;
	DWORD dwPkdSize = GetFileSize (hFile, NULL);
	CloseHandle (hFile);

	HANDLE hArcData;
	int RHCode, PFCode;
	char CmtBuf [16384];
	RARHeaderData HeaderData;
	RAROpenArchiveDataEx OpenArchiveData;

	ZeroMemory (&OpenArchiveData, sizeof (OpenArchiveData));
	OpenArchiveData.ArcName = (LPSTR)pszArchive;
	OpenArchiveData.CmtBuf = CmtBuf;
	OpenArchiveData.CmtBufSize = sizeof (CmtBuf);
	OpenArchiveData.OpenMode = RAR_OM_EXTRACT;
	
	hArcData = m_unrar.RAROpenArchiveEx (&OpenArchiveData);

	if (hArcData == NULL || OpenArchiveData.OpenResult != 0)
		return false;

	
	

	HeaderData.CmtBuf = NULL;
	DWORD dwProcessed = 0;

	CString strOutFolder = pszOutFolder;
	if (strOutFolder [strOutFolder.GetLength () - 1] != '\\')
		strOutFolder += '\\';

	vmsAC_OverwriteMode enOM;
	bool bAskOverwrite = true;

	TIME_ZONE_INFORMATION tzi;
	GetTimeZoneInformation (&tzi);

	while ((RHCode = m_unrar.RARReadHeader (hArcData, &HeaderData)) == 0)
	{
		bool bSkip = false;

		if (m_pAC) {
			if (false == m_pAC->BeforeExtract (HeaderData.FileName)) {
				RHCode = ERAR_END_ARCHIVE;
				break;
			}

			DWORD dwAttr = GetFileAttributes (strOutFolder + HeaderData.FileName);
			if (dwAttr != DWORD (-1) && (dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0)
			{
				if (bAskOverwrite)
				{
					vmsOverwriteFileInfo ofi;
					bool bForAll = false;

					CString strFile = strOutFolder + HeaderData.FileName;
					ofi.pszFile = strFile;
					UINT64 u = HeaderData.UnpSize;
					FILETIME time;
					DosDateTimeToFileTime (HIWORD (HeaderData.FileTime),
						LOWORD (HeaderData.FileTime), &time);
					*((UINT64*)&time) += Int32x32To64 (tzi.Bias, 60 * 10000000);
					ofi.ptimeNewLastWrite = &time;
					ofi.puNewSize = &u;

					m_pAC->AskOverwrite (ofi, enOM, bForAll);

					if (enOM == AC_OM_CANCEL) {
						m_errExtract = AEE_ABORTED_BY_USER;
						break;
					}

					if (bForAll)
						bAskOverwrite = false;
				}

				if (enOM == AC_OM_SKIP)
					bSkip = true;
			}
		}

		PFCode = m_unrar.RARProcessFile (hArcData, bSkip ? RAR_SKIP : RAR_EXTRACT, 
			(LPSTR)pszOutFolder, NULL);

		if (PFCode == 0) {
			if (m_pAC) {
				m_pAC->AfterExtract (HeaderData.FileName, AC_ER_OK);
				dwProcessed += HeaderData.PackSize;
				m_pAC->SetProgress (MulDiv (dwProcessed, 100, dwPkdSize));
			}
		}
		else
		{
			if (m_pAC)
				m_pAC->AfterExtract (HeaderData.FileName, AC_ER_FAILED);
			break;
		}
	}

	m_unrar.RARCloseArchive (hArcData);

	if (RHCode == ERAR_END_ARCHIVE)
		m_errExtract = AEE_NO_ERROR;

	return RHCode == ERAR_END_ARCHIVE;
}