当前位置: 首页>>代码示例>>C++>>正文


C++ LocalFileTimeToFileTime函数代码示例

本文整理汇总了C++中LocalFileTimeToFileTime函数的典型用法代码示例。如果您正苦于以下问题:C++ LocalFileTimeToFileTime函数的具体用法?C++ LocalFileTimeToFileTime怎么用?C++ LocalFileTimeToFileTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LocalFileTimeToFileTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: futime

int
futime(int fd, struct utimbuf *times)
{
  struct tm *tmb;
  SYSTEMTIME systemTime;
  FILETIME localFileTime;
  FILETIME lastWriteTime;
  FILETIME lastAccessTime;
  struct utimbuf deftimes;

  if (times == NULL) {
    time(&deftimes.modtime);
    deftimes.actime = deftimes.modtime;
    times = &deftimes;
  }

  if ((tmb = localtime(&times->modtime)) == NULL) {
    errno = EINVAL;
    return (-1);
  }

  systemTime.wYear = (WORD) (tmb->tm_year + 1900);
  systemTime.wMonth = (WORD) (tmb->tm_mon + 1);
  systemTime.wDay = (WORD) (tmb->tm_mday);
  systemTime.wHour = (WORD) (tmb->tm_hour);
  systemTime.wMinute = (WORD) (tmb->tm_min);
  systemTime.wSecond = (WORD) (tmb->tm_sec);
  systemTime.wMilliseconds = 0;

  if (!SystemTimeToFileTime(&systemTime, &localFileTime)
      || !LocalFileTimeToFileTime(&localFileTime, &lastWriteTime)) {
    errno = EINVAL;
    return(-1);
  }

  if ((tmb = localtime(&times->actime)) == NULL) {
    errno = EINVAL;
    return (-1);
  }

  systemTime.wYear = (WORD) (tmb->tm_year + 1900);
  systemTime.wMonth = (WORD) (tmb->tm_mon + 1);
  systemTime.wDay = (WORD) (tmb->tm_mday);
  systemTime.wHour = (WORD) (tmb->tm_hour);
  systemTime.wMinute = (WORD) (tmb->tm_min);
  systemTime.wSecond = (WORD) (tmb->tm_sec);
  systemTime.wMilliseconds = 0;

  if (!SystemTimeToFileTime(&systemTime, &localFileTime)
      || !LocalFileTimeToFileTime(&localFileTime, &lastAccessTime)) {
    errno = EINVAL;
    return(-1);
  }

  if (!SetFileTime(_fdtab[fd].hnd, NULL, &lastAccessTime, &lastWriteTime)) {
    errno = EINVAL;
    return(-1);
  }
  return (0);
}
开发者ID:mmcx,项目名称:cegcc,代码行数:60,代码来源:utime.c

示例2: AfxTimeToFileTime

void AFX_CDECL AfxTimeToFileTime(const CTime& time, LPFILETIME pFileTime)
{
	ASSERT(pFileTime != NULL);

	if (pFileTime == NULL) 
	{
		AfxThrowInvalidArgException();
	}

	SYSTEMTIME sysTime;
	sysTime.wYear = (WORD)time.GetYear();
	sysTime.wMonth = (WORD)time.GetMonth();
	sysTime.wDay = (WORD)time.GetDay();
	sysTime.wHour = (WORD)time.GetHour();
	sysTime.wMinute = (WORD)time.GetMinute();
	sysTime.wSecond = (WORD)time.GetSecond();
	sysTime.wMilliseconds = 0;

	// convert system time to local file time
	FILETIME localTime;
	if (!SystemTimeToFileTime((LPSYSTEMTIME)&sysTime, &localTime))
		CFileException::ThrowOsError((LONG)::GetLastError());

	// convert local file time to UTC file time
	if (!LocalFileTimeToFileTime(&localTime, pFileTime))
		CFileException::ThrowOsError((LONG)::GetLastError());
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:27,代码来源:filest.cpp

示例3: ASSERT

bool CArchiverUNARJ::InspectArchiveGetWriteTime(FILETIME &FileTime)
{
	if(!m_hInspectArchive){
		ASSERT(!"Open an Archive First!!!\n");
		return false;
	}
	//拡張版関数で時刻取得
	if(ArchiverGetWriteTimeEx){
		FILETIME TempTime;
		if(!ArchiverGetWriteTimeEx(m_hInspectArchive,&TempTime))return false;
		if(!LocalFileTimeToFileTime(&TempTime,&FileTime))return false;
		return true;
	}
	//通常版関数で時刻取得
	else if(ArchiverGetWriteTime){
		DWORD UnixTime=ArchiverGetWriteTime(m_hInspectArchive);
		if(-1==UnixTime){
			return false;
		}
		//time_tからFileTimeへ変換
		LONGLONG ll = Int32x32To64(UnixTime, 10000000) + 116444736000000000;
		FileTime.dwLowDateTime = (DWORD) ll;
		FileTime.dwHighDateTime = (DWORD)(ll >>32);
		return true;
	}
	else{
开发者ID:Claybird,项目名称:lhaforge,代码行数:26,代码来源:ArchiverUNARJ.cpp

示例4: format

/* change_file_date : change the date/time of a file
    filename : the filename of the file where date/time must be modified
    dosdate : the new date at the MSDos format (4 bytes)
    tmu_date : the SAME new date at the tm_unz format */
void ChangeFileDate( const char *filename, uLong dosdate, tm_unz tmu_date )
{
#ifdef WIN32
  HANDLE hFile;
  FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;

  hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
                      0,NULL,OPEN_EXISTING,0,NULL);
  GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
  DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
  LocalFileTimeToFileTime(&ftLocal,&ftm);
  SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
  CloseHandle(hFile);
#else
  struct utimbuf ut;
  struct tm newdate;
  newdate.tm_sec = tmu_date.tm_sec;
  newdate.tm_min=tmu_date.tm_min;
  newdate.tm_hour=tmu_date.tm_hour;
  newdate.tm_mday=tmu_date.tm_mday;
  newdate.tm_mon=tmu_date.tm_mon;
  if (tmu_date.tm_year > 1900)
      newdate.tm_year=tmu_date.tm_year - 1900;
  else
      newdate.tm_year=tmu_date.tm_year ;
  newdate.tm_isdst=-1;

  ut.actime=ut.modtime=mktime(&newdate);
  utime(filename,&ut);
#endif
}
开发者ID:WildGenie,项目名称:Scarab,代码行数:35,代码来源:miniunzip.cpp

示例5: format

/* change_file_date : change the date/time of a file
    filename : the filename of the file where date/time must be modified
    dosdate : the new date at the MSDos format (4 bytes)
    tmu_date : the SAME new date at the tm_unz format */
void change_file_date(const char *filename,uLong dosdate,tm_unz tmu_date)
{
#ifdef WIN32
  HANDLE hFile;
  FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;

  hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE,
                      0,NULL,OPEN_EXISTING,0,NULL);
  GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
  DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
  LocalFileTimeToFileTime(&ftLocal,&ftm);
  SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
  CloseHandle(hFile);
#elif defined (unix) || defined (__TURBOC__) || defined (_MSV_VER) || defined (__WATCOMC__)
  struct utimbuf ut;
  struct tm newdate;
  newdate.tm_sec = tmu_date.tm_sec;
  newdate.tm_min=tmu_date.tm_min;
  newdate.tm_hour=tmu_date.tm_hour;
  newdate.tm_mday=tmu_date.tm_mday;
  newdate.tm_mon=tmu_date.tm_mon;
  if (tmu_date.tm_year > 1900)
      newdate.tm_year=tmu_date.tm_year - 1900;
  else
      newdate.tm_year=tmu_date.tm_year ;
  newdate.tm_isdst=-1;

  ut.actime=ut.modtime=mktime(&newdate);
  utime(filename,&ut);
#else
#error No implementation defined to set file date
#endif
}
开发者ID:CivilPol,项目名称:sdcboot,代码行数:37,代码来源:munzlib.c

示例6: __FromDOSDT

void __FromDOSDT( unsigned short d, unsigned short t, FILETIME *NT_stamp )
{
    FILETIME local_ft;

    DosDateTimeToFileTime( d, t, &local_ft );
    LocalFileTimeToFileTime( &local_ft, NT_stamp );
}
开发者ID:Ukusbobra,项目名称:open-watcom-v2,代码行数:7,代码来源:ntdirinf.c

示例7: _RevertTimeValue

TimeValue System::LocalToUTCTime( TimeValue iLocalTime, TimeUnit iResolution, const TimeZone * pTimeZone ) const
{
    FILETIME hFlatTimeLocal;
    _RevertTimeValue( &hFlatTimeLocal, iLocalTime, iResolution );

    if ( pTimeZone == NULL ) {
        FILETIME hFlatTimeUTC;
        BOOL bRes = LocalFileTimeToFileTime( &hFlatTimeLocal, &hFlatTimeUTC );
        DebugAssert( bRes != FALSE );

        return _ConvertTimeValue( &hFlatTimeUTC, iResolution );
    } else {
        TIME_ZONE_INFORMATION hTimeZone;
        _RevertTimeZone( &hTimeZone, pTimeZone );

        SYSTEMTIME hSystemTimeLocal;
        BOOL bRes = FileTimeToSystemTime( &hFlatTimeLocal, &hSystemTimeLocal );
        DebugAssert( bRes != FALSE );

        SYSTEMTIME hSystemTimeUTC;
        bRes = TzSpecificLocalTimeToSystemTime( &hTimeZone, &hSystemTimeLocal, &hSystemTimeUTC );
        DebugAssert( bRes != FALSE );

        FILETIME hFlatTimeUTC;
        bRes = SystemTimeToFileTime( &hSystemTimeUTC, &hFlatTimeUTC );
        DebugAssert( bRes != FALSE );

        return _ConvertTimeValue( &hFlatTimeUTC, iResolution );
    }
}
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:30,代码来源:System.cpp

示例8: TimeToFileTime

FileTime TimeToFileTime(Time time)
{
#ifdef PLATFORM_WIN32
	SYSTEMTIME tm;
	Zero(tm);
	tm.wYear   = time.year;
	tm.wMonth  = time.month;
	tm.wDay    = time.day;
	tm.wHour   = time.hour;
	tm.wMinute = time.minute;
	tm.wSecond = time.second;
	FileTime ftl, ftg;
	SystemTimeToFileTime(&tm, &ftl);
	LocalFileTimeToFileTime(&ftl, &ftg);
	return ftg;
#endif
#ifdef PLATFORM_POSIX
	struct tm t;
	t.tm_sec  = time.second;
	t.tm_min  = time.minute;
	t.tm_hour = time.hour;
	t.tm_mday = time.day;
	t.tm_mon  = time.month - 1;
	t.tm_year = time.year - 1900;
	return mktime(&t);
#endif
}
开发者ID:pedia,项目名称:raidget,代码行数:27,代码来源:Path.cpp

示例9: memset

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;
	}
开发者ID:CyberShadow,项目名称:FAR,代码行数:33,代码来源:rar.Class.cpp

示例10: _dos_setftime

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));
}
开发者ID:doniexun,项目名称:OrangeC,代码行数:7,代码来源:dos_sft.c

示例11: filetime_dt

static time_t filetime_dt( FILETIME t_utc )
{
    static int calc_time_diff = 1;
    static double time_diff;
    if ( calc_time_diff )
    {
        struct tm t0_;
        FILETIME f0_local;
        FILETIME f0_;
        SYSTEMTIME s0_;
        GetSystemTime( &s0_ );
        t0_.tm_year = s0_.wYear-1900;
        t0_.tm_mon = s0_.wMonth-1;
        t0_.tm_wday = s0_.wDayOfWeek;
        t0_.tm_mday = s0_.wDay;
        t0_.tm_hour = s0_.wHour;
        t0_.tm_min = s0_.wMinute;
        t0_.tm_sec = s0_.wSecond;
        t0_.tm_isdst = 0;
        SystemTimeToFileTime( &s0_, &f0_local );
        LocalFileTimeToFileTime( &f0_local, &f0_ );
        time_diff = filetime_seconds( f0_ ) - (double)mktime( &t0_ );
        calc_time_diff = 0;
    }
    return ceil( filetime_seconds( t_utc ) - time_diff );
}
开发者ID:4ukuta,项目名称:core,代码行数:26,代码来源:execnt.c

示例12: cnv_tar2win_time

void cnv_tar2win_time(time_t tartime, FILETIME *ftm)
{
#ifdef HAS_LIBC_CAL_FUNCS
		  FILETIME ftLocal;
		  SYSTEMTIME st;
		  struct tm localt;
 
		  localt = *localtime(&tartime);
		  
		  st.wYear = (WORD)localt.tm_year+1900;
		  st.wMonth = (WORD)localt.tm_mon+1;    /* 1 based, not 0 based */
		  st.wDayOfWeek = (WORD)localt.tm_wday;
		  st.wDay = (WORD)localt.tm_mday;
		  st.wHour = (WORD)localt.tm_hour;
		  st.wMinute = (WORD)localt.tm_min;
		  st.wSecond = (WORD)localt.tm_sec;
		  st.wMilliseconds = 0;
		  SystemTimeToFileTime(&st,&ftLocal);
		  LocalFileTimeToFileTime(&ftLocal,ftm);
#else
	// avoid casts further below
    LONGLONG *t = (LONGLONG *)ftm;

	// tartime == number of seconds since midnight Jan 1 1970 (00:00:00)
	// convert to equivalent 100 nanosecond intervals
	*t = UInt32x32To64(tartime, 10000000UL);

	// now base on 1601, add number of 100 nansecond intervals between 1601 & 1970
	*t += HUNDREDSECINTERVAL;  /* 116444736000000000i64; */
#endif
}
开发者ID:mwiebe,项目名称:nsis-untgz,代码行数:31,代码来源:untar.c

示例13: CreateFileW

bool vtUnzip::change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date)
{
	bool bOK = false;
#ifdef _WIN32
#if SUPPORT_WSTRING
	wstring2 ws;
	ws.from_utf8(filename);
	HANDLE hFile = CreateFileW(ws.c_str(), GENERIC_READ | GENERIC_WRITE, 0,NULL,
		OPEN_EXISTING,0,NULL);
#else
	HANDLE hFile = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE, 0,NULL,
		OPEN_EXISTING,0,NULL);
#endif
	bOK = (hFile != INVALID_HANDLE_VALUE);
	if (bOK)
	{
		FILETIME ftm,ftLocal,ftLastAcc;
		BOOL bBOK = GetFileTime(hFile,NULL,&ftLastAcc,NULL);
		bOK = (bBOK == TRUE);
		DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
		LocalFileTimeToFileTime(&ftLocal,&ftm);
		SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
		CloseHandle(hFile);
	}
#else
	// TODO: Unix implementation, if needed.  Do we care about file dates?
	bOK = true;
#endif
	return bOK;
}
开发者ID:kalwalt,项目名称:ofxVTerrain,代码行数:30,代码来源:vtUnzip.cpp

示例14: GetCombinedDateTime

void GetCombinedDateTime ( HWND hwnd, UINT idcDatePicker, UINT idcTimePicker,
                           FILETIME* pFiletime )
{
SYSTEMTIME st = {0}, stDate = {0}, stTime = {0};
FILETIME   ftLocal;

    SendDlgItemMessage ( hwnd, idcDatePicker, DTM_GETSYSTEMTIME,
                         0, (LPARAM) &stDate );

    if ( 0 != idcTimePicker )
        {
        SendDlgItemMessage ( hwnd, idcTimePicker, DTM_GETSYSTEMTIME,
                             0, (LPARAM) &stTime );
        }

    st.wMonth  = stDate.wMonth;
    st.wDay    = stDate.wDay;
    st.wYear   = stDate.wYear;
    st.wHour   = stTime.wHour;
    st.wMinute = stTime.wMinute;
    st.wSecond = stTime.wSecond;

    SystemTimeToFileTime ( &st, &ftLocal );
    LocalFileTimeToFileTime ( &ftLocal, pFiletime );
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:25,代码来源:FileTimeShlExt.cpp

示例15: to_utc

vtime_t to_utc(vtime_t _time)
{
  __int64 local = (__int64)(_time * 10000000 + epoch_adj);
  __int64 utc;

  LocalFileTimeToFileTime((FILETIME*)&local, (FILETIME*)&utc);
  return vtime_t(utc - epoch_adj) / 10000000;
}
开发者ID:9060,项目名称:ac3filter.valib,代码行数:8,代码来源:vtime.cpp


注:本文中的LocalFileTimeToFileTime函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。