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


C++ FileTimeToLocalFileTime函数代码示例

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


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

示例1: format_timestamp

static void format_timestamp(uint64_t seconds, int microseconds, char *buffer, int length,
                             char *date_separator, char *date_time_separator, char *time_separator) {
	ULONGLONG timestamp = 0;
	ULONGLONG offset_to_1970 = 116444736000000000;
	SYSTEMTIME st;
	FILETIME ft, ft_local;

	timestamp = Int32x32To64(seconds, 10000000) + offset_to_1970;
	ft.dwHighDateTime = (DWORD)((timestamp >> 32) & 0xFFFFFFFF);
	ft.dwLowDateTime = (DWORD)(timestamp & 0xFFFFFFFF);

	FileTimeToLocalFileTime(&ft, &ft_local);
	FileTimeToSystemTime(&ft_local, &st);

	if (microseconds < 0) {
		_snprintf(buffer, length, "%d%s%02d%s%02d%s%02d%s%02d%s%02d",
		          st.wYear, date_separator, st.wMonth, date_separator, st.wDay, date_time_separator,
		          st.wHour, time_separator, st.wMinute, time_separator, st.wSecond);
	} else {
		_snprintf(buffer, length, "%d%s%02d%s%02d%s%02d%s%02d%s%02d.%06d",
		          st.wYear, date_separator, st.wMonth, date_separator, st.wDay, date_time_separator,
		          st.wHour, time_separator, st.wMinute, time_separator, st.wSecond, microseconds);
	}
}
开发者ID:Loremipsum1988,项目名称:brickd,代码行数:24,代码来源:logviewer.c

示例2: timeT

CMSTime::CMSTime(const FILETIME& fileTime, int nDST)
{
	// first convert file time (UTC time) to local time
	FILETIME localTime;
	if (!FileTimeToLocalFileTime(&fileTime, &localTime))
	{
		m_time = 0;
		//AtlThrow(E_INVALIDARG);
		return;
	}

	// then convert that time to system time
	SYSTEMTIME sysTime;
	if (!FileTimeToSystemTime(&localTime, &sysTime))
	{
		m_time = 0;
		//AtlThrow(E_INVALIDARG);		
		return;
	}

	// then convert the system time to a time_t (C-runtime local time)
	CMSTime timeT(sysTime, nDST);
	*this = timeT;
}
开发者ID:juhuaguai,项目名称:duilib,代码行数:24,代码来源:mstime.cpp

示例3: Filesets_Dump_OnInitDialog

void Filesets_Dump_OnInitDialog (HWND hDlg, LPSET_DUMP_PARAMS psdp)
{
   TCHAR szServer[ cchNAME ];
   TCHAR szAggregate[ cchNAME ];
   TCHAR szFileset[ cchNAME ];
   psdp->lpi->GetServerName (szServer);
   psdp->lpi->GetAggregateName (szAggregate);
   psdp->lpi->GetFilesetName (szFileset);

   TCHAR szText[ cchRESOURCE ];
   GetDlgItemText (hDlg, IDC_DUMP_FULL, szText, cchRESOURCE);

   LPTSTR pszText = FormatString (szText, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
   SetDlgItemText (hDlg, IDC_DUMP_FULL, pszText);
   FreeString (pszText);

   pszText = FormatString (IDS_SET_DUMP_NAME, TEXT("%s"), szFileset);
   SetDlgItemText (hDlg, IDC_DUMP_FILENAME, pszText);
   FreeString (pszText);

   // Get the local system time
   SYSTEMTIME st;
   GetSystemTime (&st);
   FILETIME ft;
   SystemTimeToFileTime (&st, &ft);
   FILETIME lft;
   FileTimeToLocalFileTime (&ft, &lft);
   FileTimeToSystemTime (&lft, &st);

   DA_SetDate (GetDlgItem (hDlg, IDC_DUMP_DATE), &st);
   TI_SetTime (GetDlgItem (hDlg, IDC_DUMP_TIME), &st);

   CheckDlgButton (hDlg, IDC_DUMP_FULL, TRUE);
   Filesets_Dump_OnSelect (hDlg);
   Filesets_Dump_EnableOK (hDlg);
}
开发者ID:bagdxk,项目名称:openafs,代码行数:36,代码来源:set_dump.cpp

示例4: ConvertDate

void ConvertDate(const FILETIME& ft,wchar_t *DateText,wchar_t *TimeText)
{
	if (ft.dwHighDateTime==0 && ft.dwLowDateTime==0)
	{
		if (DateText!=NULL)
			*DateText=0;

		if (TimeText!=NULL)
			*TimeText=0;

		return;
	}

	SYSTEMTIME st;
	FILETIME ct;
	FileTimeToLocalFileTime(&ft,&ct);
	FileTimeToSystemTime(&ct,&st);

	if (TimeText!=NULL)
		GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, 0, TimeText, MAX_DATETIME);

	if (DateText!=NULL)
		GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, 0, DateText, MAX_DATETIME);
}
开发者ID:CyberShadow,项目名称:FAR,代码行数:24,代码来源:Pmix.cpp

示例5: EnterCriticalSection

BOOL CStreamVideoSource::GetRawImage(BYTE **pRawData, FILETIME *timestamp, DWORD *bEOF )
{

	// Lock the image here and don't unlock until we get the frame back
	EnterCriticalSection(&m_csBufLock);
	*bEOF = FALSE;

	if( m_bGotVideoFrame )
	{
		// Get the next frame
		*pRawData = m_pAlignedImg;

		// Need Time stamp
		GetSystemTimeAsFileTime(timestamp);
		FileTimeToLocalFileTime(timestamp, timestamp);

		m_bGotVideoFrame = FALSE;
		return TRUE;
	}
	else
	{
		// Nothing.. unlock
		LeaveCriticalSection(&m_csBufLock);

		// Check for process exit
		if( WAIT_OBJECT_0 == WaitForSingleObject( m_piStreamer.hProcess, 0 ) )
		{
			// Child process has disappeared (exited)
			*bEOF = TRUE;

			m_bRun = FALSE;
			CleanupChild();
		}
		return FALSE;
	}
}
开发者ID:anyboo,项目名称:SPlayer,代码行数:36,代码来源:StreamVideoSource.cpp

示例6: posixemu_stat

int posixemu_stat(const char *name, struct stat *statbuf)
{
	char buf[1024];
	DWORD attr;
	FILETIME ft, lft;

	fname_atow(name,buf,sizeof buf);

	if ((attr = getattr(buf,&ft,(size_t*)&statbuf->st_size)) == (DWORD)~0)
	{
		lasterror = GetLastError();
		return -1;
	}
	else
	{
        statbuf->st_mode = (attr & FILE_ATTRIBUTE_READONLY) ? FILEFLAG_READ: FILEFLAG_READ | FILEFLAG_WRITE;
		if (attr & FILE_ATTRIBUTE_ARCHIVE) statbuf->st_mode |= FILEFLAG_ARCHIVE;
		if (attr & FILE_ATTRIBUTE_DIRECTORY) statbuf->st_mode |= FILEFLAG_DIR;
		FileTimeToLocalFileTime(&ft,&lft);
		statbuf->st_mtime = (*(__int64 *)&lft-((__int64)(369*365+89)*(__int64)(24*60*60)*(__int64)10000000))/(__int64)10000000;
	}

	return 0;
}
开发者ID:lleoha,项目名称:WinFellow,代码行数:24,代码来源:POSIXEMU.C

示例7: hal_getsysdate

static TINT
hal_getsysdate(struct THALBase *hal, TDATE *datep, TINT *dsbiasp)
{
	union { LARGE_INTEGER li; FILETIME ft; } utime;
	union { LARGE_INTEGER li; FILETIME ft; } ltime;
	TUINT64 syst;
	TINT dsbias;

	GetSystemTimeAsFileTime(&utime.ft);
	syst = utime.li.QuadPart / 10; /* to microseconds since 1.1.1601 */

	FileTimeToLocalFileTime(&utime.ft, &ltime.ft);
	dsbias = (TINT) ((utime.li.QuadPart - ltime.li.QuadPart) / 10000000);

	if (dsbiasp)
		*dsbiasp = dsbias;
	else
		syst -= (TINT64) dsbias * 1000000;

	if (datep)
		datep->tdt_Int64 = syst;

	return 0;
}
开发者ID:callcc,项目名称:tekui,代码行数:24,代码来源:hal.c

示例8: filetime

uLong filetime(
	const char *filename,	/* name of file to get info on */
	tm_zip *tmzip,			/* return value: access, modific. and creation times */
	uLong *dt)				/* dostime */
/*****************************/
#ifdef WIN32
{
  int ret = 0;
  {
	  FILETIME ftLocal;
	  HANDLE hFind;
	  WIN32_FIND_DATA  ff32;

	  hFind = FindFirstFile(filename,&ff32);
	  if (hFind != INVALID_HANDLE_VALUE)
	  {
		FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
		FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
		FindClose(hFind);
		ret = 1;
	  }
  }
  return ret;
}
开发者ID:BackupTheBerlios,项目名称:kicad-svn,代码行数:24,代码来源:minizip.c

示例9: defined

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

# if defined (ACE_HAS_WINCE)
ACE_TCHAR *
ACE_OS::ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen)
{
  // buflen must be at least 26 wchar_t long.
  if (buflen < 26)              // Again, 26 is a magic number.
    {
      errno = ERANGE;
      return 0;
    }
  // This is really stupid, converting FILETIME to timeval back and
  // forth.  It assumes FILETIME and DWORDLONG are the same structure
  // internally.
  ULARGE_INTEGER _100ns;
  _100ns.QuadPart = (DWORDLONG) *clock * 10000 * 1000
                     + ACE_Time_Value::FILETIME_to_timval_skew;
  FILETIME file_time;
  file_time.dwLowDateTime = _100ns.LowPart;
  file_time.dwHighDateTime = _100ns.HighPart;

  FILETIME localtime;
  SYSTEMTIME systime;
  FileTimeToLocalFileTime (&file_time, &localtime);
  FileTimeToSystemTime (&localtime, &systime);
  ACE_OS::sprintf (buf, ACE_OS_CTIME_R_FMTSTR,
                   ACE_OS_day_of_week_name[systime.wDayOfWeek],
                   ACE_OS_month_name[systime.wMonth - 1],
                   systime.wDay,
                   systime.wHour,
                   systime.wMinute,
                   systime.wSecond,
                   systime.wYear);
  return buf;
}
开发者ID:08keelr,项目名称:TrinityCore,代码行数:36,代码来源:OS_NS_time.cpp

示例10: DragQueryFile

void CFileEncryptDlg::OnDropFiles(HDROP hDropInfo)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	int DropCount = DragQueryFile(hDropInfo, -1, NULL, 0);
	CString FileInfo;
	TCHAR *pName;
	WIN32_FIND_DATA FindFileData;
	SYSTEMTIME mysystime;
	FILETIME loctime;
	if (DropCount <= 1)
	{
		HANDLE hFile;
		int NameSize = DragQueryFile(hDropInfo, 0, NULL, 0);
		pName = new TCHAR[NameSize + 1];
		DragQueryFile(hDropInfo, 0, pName, NameSize+1);
		hFile = FindFirstFile(pName, &FindFileData);
		FindClose(hFile);
		if (hFile == INVALID_HANDLE_VALUE)
		{
			FileInfo = _T("是不是把硬盘\\U盘\\CD驱动器拖拽进来啦,这样是不行滴!");
			SetButtonFalse();
		}		
		else if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0x10)
		{
			FileInfo = _T("不能对文件夹进行操作!");
			SetButtonFalse();
		}
		else if (FindFileData.nFileSizeLow == 0 && FindFileData.nFileSizeHigh == 0)
		{
			FileInfo = _T("文件大小为0字节,无需操作!");
			SetButtonFalse();
		}
		else
		{
			// 文件名称
			str_FileName = pName;
			FileInfo += str_FileName;
			FileInfo += _T("\r\n");
			CString str_data;
			// 文件大小
			// llFileSize = (FindFileData.nFileSizeHigh << 32) + FindFileData.nFileSizeLow; // 行为未定义,但是运行正常,会首先转换为LONGLONG,然后左移
			llFileSize = FindFileData.nFileSizeHigh;
			llFileSize <<= 32;
			llFileSize += FindFileData.nFileSizeLow;
			str_data.Format(_T("文件大小:%I64d字节\r\n"), llFileSize);
			FileInfo += str_data;
			// 文件创建时间
			// 转化为本地时间,否则会有8小时误差
			FileTimeToLocalFileTime(&FindFileData.ftLastWriteTime, &loctime);
			FileTimeToSystemTime(&loctime, &mysystime);
			str_data.Format(_T("最后修改时间:%d年%d月%d日 %d:%02d:%02d"), mysystime.wYear, mysystime.wMonth, 
				mysystime.wDay, mysystime.wHour, mysystime.wMinute, mysystime.wSecond);
			FileInfo += str_data;
			GetDlgItem(IDC_ENCRYPT)->EnableWindow(TRUE);
			GetDlgItem(IDC_DECRYPT)->EnableWindow(TRUE);
		}
 		delete[] pName;
		pName = NULL;
		DragFinish(hDropInfo);
	}
	else
	{
		FileInfo = _T("本程序只支持单个文件拖拽加密!");
	}	
	SetDlgItemText(IDC_FILE_INFORMATION, FileInfo);
	
	CDialogEx::OnDropFiles(hDropInfo);
}
开发者ID:Ruijie-Qin,项目名称:FileEncrypt,代码行数:68,代码来源:FileEncryptDlg.cpp

示例11: propBasicQueryKey

/*
* propBasicQueryKey
*
* Purpose:
*
* Set information values for Key object type
*
* If ExtendedInfoAvailable is FALSE then it calls propSetDefaultInfo to set Basic page properties
*
*/
VOID propBasicQueryKey(
    _In_ PROP_OBJECT_INFO *Context,
    _In_ HWND hwndDlg,
    _In_ BOOL ExtendedInfoAvailable
)
{
    NTSTATUS    status;
    ULONG       bytesNeeded;
    HANDLE      hObject;
    TIME_FIELDS	SystemTime;
    WCHAR       szBuffer[MAX_PATH];

    KEY_FULL_INFORMATION  kfi;

    SetDlgItemText(hwndDlg, ID_KEYSUBKEYS, T_CannotQuery);
    SetDlgItemText(hwndDlg, ID_KEYVALUES, T_CannotQuery);
    SetDlgItemText(hwndDlg, ID_KEYLASTWRITE, T_CannotQuery);

    if (Context == NULL) {
        return;
    }

    //
    // Open Key object.
    //
    hObject = NULL;
    if (!propOpenCurrentObject(Context, &hObject, KEY_QUERY_VALUE)) {
        return;
    }

    RtlSecureZeroMemory(&kfi, sizeof(KEY_FULL_INFORMATION));
    status = NtQueryKey(hObject, KeyFullInformation, &kfi,
        sizeof(KEY_FULL_INFORMATION), &bytesNeeded);

    if (NT_SUCCESS(status)) {

        //Subkeys count
        RtlSecureZeroMemory(szBuffer, sizeof(szBuffer));
        ultostr(kfi.SubKeys, _strend(szBuffer));
        SetDlgItemText(hwndDlg, ID_KEYSUBKEYS, szBuffer);

        //Values count
        RtlSecureZeroMemory(szBuffer, sizeof(szBuffer));
        ultostr(kfi.Values, _strend(szBuffer));
        SetDlgItemText(hwndDlg, ID_KEYVALUES, szBuffer);

        //LastWrite time
        RtlSecureZeroMemory(&SystemTime, sizeof(SystemTime));
        FileTimeToLocalFileTime((PFILETIME)&kfi.LastWriteTime,
            (PFILETIME)&kfi.LastWriteTime);
        RtlTimeToTimeFields((PLARGE_INTEGER)&kfi.LastWriteTime,
            (PTIME_FIELDS)&SystemTime);

        //Month starts from 0 index
        if (SystemTime.Month - 1 < 0) SystemTime.Month = 1;
        if (SystemTime.Month > 12) SystemTime.Month = 12;

        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        wsprintf(szBuffer, FORMATTED_TIME_DATE_VALUE,
            SystemTime.Hour,
            SystemTime.Minute,
            SystemTime.Second,
            SystemTime.Day,
            Months[SystemTime.Month - 1],
            SystemTime.Year);

        SetDlgItemText(hwndDlg, ID_KEYLASTWRITE, szBuffer);
    }

    //
    // Query object basic and type info if needed.
    //
    if (ExtendedInfoAvailable == FALSE) {
        propSetDefaultInfo(Context, hwndDlg, hObject);
    }
    NtClose(hObject);
}
开发者ID:songbei6,项目名称:WinObjEx64,代码行数:87,代码来源:propBasic.c

示例12: propBasicQuerySymlink

/*
* propBasicQuerySymlink
*
* Purpose:
*
* Set information values for SymbolicLink object type
*
* If ExtendedInfoAvailable is FALSE then it calls propSetDefaultInfo to set Basic page properties
*
*/
VOID propBasicQuerySymlink(
    _In_ PROP_OBJECT_INFO *Context,
    _In_ HWND hwndDlg,
    _In_ BOOL ExtendedInfoAvailable
)
{
    NTSTATUS    status;
    ULONG       bytesNeeded;
    HANDLE      hObject;
    LPWSTR      lpLinkTarget;
    TIME_FIELDS	SystemTime;
    WCHAR       szBuffer[MAX_PATH];

    OBJECT_BASIC_INFORMATION obi;

    SetDlgItemText(hwndDlg, ID_OBJECT_SYMLINK_TARGET, T_CannotQuery);
    SetDlgItemText(hwndDlg, ID_OBJECT_SYMLINK_CREATION, T_CannotQuery);

    if (Context == NULL) {
        return;
    }

    //
    // Open SymbolicLink object.
    //
    hObject = NULL;
    if (!propOpenCurrentObject(Context, &hObject, SYMBOLIC_LINK_QUERY)) {
        return;
    }

    //
    // Copy link target from main object list for performance reasons.
    // So we don't need to query same data again.
    //
    lpLinkTarget = Context->lpDescription;
    if (lpLinkTarget) {
        SetDlgItemText(hwndDlg, ID_OBJECT_SYMLINK_TARGET, lpLinkTarget);
    }

    //Query Link Creation Time
    RtlSecureZeroMemory(&obi, sizeof(OBJECT_BASIC_INFORMATION));

    status = NtQueryObject(hObject, ObjectBasicInformation, &obi,
        sizeof(OBJECT_BASIC_INFORMATION), &bytesNeeded);

    if (NT_SUCCESS(status)) {
        FileTimeToLocalFileTime((PFILETIME)&obi.CreationTime, (PFILETIME)&obi.CreationTime);
        RtlSecureZeroMemory(&SystemTime, sizeof(SystemTime));
        RtlTimeToTimeFields((PLARGE_INTEGER)&obi.CreationTime, (PTIME_FIELDS)&SystemTime);

        //Month starts from 0 index
        if (SystemTime.Month - 1 < 0) SystemTime.Month = 1;
        if (SystemTime.Month > 12) SystemTime.Month = 12;

        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        wsprintf(szBuffer, FORMATTED_TIME_DATE_VALUE,
            SystemTime.Hour,
            SystemTime.Minute,
            SystemTime.Second,
            SystemTime.Day,
            Months[SystemTime.Month - 1],
            SystemTime.Year);

        SetDlgItemText(hwndDlg, ID_OBJECT_SYMLINK_CREATION, szBuffer);
    }

    //
    // Query object basic and type info if needed.
    //
    if (ExtendedInfoAvailable == FALSE) {
        propSetDefaultInfo(Context, hwndDlg, hObject);
    }
    NtClose(hObject);
}
开发者ID:songbei6,项目名称:WinObjEx64,代码行数:84,代码来源:propBasic.c

示例13: CheckRecursivFilesFromSizeAndEM

//----------------------------------------------------------------
void CheckRecursivFilesFromSizeAndEM(DWORD iitem, char *remote_name, long long int size, char *MD5, char *SHA256, BOOL recursif, char*source)
{
  #ifdef DEBUG_MODE_FILES
  AddMsg(h_main,"DEBUG","files:CheckRecursivFilesFromSizeAndEM START",remote_name);
  #endif
  WIN32_FIND_DATA data;
  char tmp_path[LINE_SIZE]="", tmp_remote_name[LINE_SIZE]="", date[MAX_PATH]="\0\0\0";

  //search
  BOOL exist;
  HANDLE hfile, hfind;
  LARGE_INTEGER filesize;
  char s_sha[SHA256_SIZE]="",s_md5[MAX_PATH];
  FILETIME LocalFileTime;
  SYSTEMTIME SysTimeModification;

  snprintf(tmp_path,LINE_SIZE,"%s\\*.*",remote_name);
  hfind = FindFirstFile(tmp_path, &data);
  if (hfind != INVALID_HANDLE_VALUE && scan_start)
  {
    do
    {
      if (data.cFileName[0] == '.' && (data.cFileName[1] == 0 || (data.cFileName[2] == 0 && data.cFileName[1] == '.')))continue;

      #ifdef DEBUG_MODE_FILES
      AddMsg(h_main,(char*)"DEBUG S(CheckRecursivFilesFromSizeAndEM)",remote_name,(char*)data.cFileName);
      #endif

      if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && recursif)
      {
        snprintf(tmp_remote_name,LINE_SIZE,"%s\\%s",remote_name,data.cFileName);

        #ifdef DEBUG_MODE_FILES
        AddMsg(h_main,(char*)"DEBUG D(CheckRecursivFilesFromSizeAndEM)",tmp_remote_name,(char*)"");
        #endif

        CheckRecursivFilesFromSizeAndEM(iitem, tmp_remote_name, size, MD5, SHA256, recursif, source);
        continue;
      }

      exist = FALSE;
      filesize.HighPart = data.nFileSizeHigh;
      filesize.LowPart  = data.nFileSizeLow;

      if (filesize.QuadPart == size || size == -1)
      {
        snprintf(tmp_remote_name,LINE_SIZE,"%s\\%s",remote_name,data.cFileName);

        s_md5[0] = 0;
        s_sha[0] = 0;

        if (MD5[0] != 0 || SHA256[0] != 0 || (SHA256[0] == 0 && MD5[0] == 0))
        {
          //make MD5 and SHA256 hashes
          //MD5
          hfile = CreateFile(tmp_remote_name,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0);
          if (hfile != INVALID_HANDLE_VALUE)
          {
            FileToMd5(hfile, s_md5);
            CloseHandle(hfile);

            //SHA256
            hfile = CreateFile(tmp_remote_name,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0);
            if (hfile != INVALID_HANDLE_VALUE)
            {
              FileToSHA256(hfile, s_sha);
              CloseHandle(hfile);
            }
          }

          if (MD5[0] == 0 && SHA256[0] == 0)exist = TRUE;
          else
          {
            if(MD5[0] != 0 && compare_nocas(MD5,s_md5))exist = TRUE;
            else if(SHA256[0] != 0 && compare_nocas(SHA256,s_sha))exist = TRUE;
          }

          if (exist && (filesize.QuadPart!=0 || (data.ftLastWriteTime.dwHighDateTime != 0 && data.ftLastWriteTime.dwLowDateTime != 0)))
          {
            date[0] = 0;
            FileTimeToLocalFileTime(&(data.ftLastWriteTime), &LocalFileTime);
            FileTimeToSystemTime(&LocalFileTime, &SysTimeModification);
            snprintf(date,MAX_PATH,"[Last_modification:%02d/%02d/%02d-%02d:%02d:%02d,Size:%lo]"
                         ,SysTimeModification.wYear,SysTimeModification.wMonth,SysTimeModification.wDay
                         ,SysTimeModification.wHour,SysTimeModification.wMinute,SysTimeModification.wSecond,filesize.QuadPart);

            if (s_sha[0] != 0)
            {
              snprintf(tmp_remote_name,LINE_SIZE,"%s %s;MD5;%s;%s;%s",tmp_remote_name,date,s_md5[0]==0?"":s_md5,SHA1_enable?"SHA1":"SHA256",s_sha[0]==0?"":s_sha);
            }else if (s_md5[0] != 0)
            {
              snprintf(tmp_remote_name,LINE_SIZE,"%s %s;MD5;%s;;",tmp_remote_name,date,s_md5);
            }else snprintf(tmp_remote_name,LINE_SIZE,"%s %s;;;;",tmp_remote_name,date);

            AddMsg(h_main,(char*)"FOUND (File2)",tmp_remote_name,(char*)"");
            AddLSTVUpdateItem(tmp_remote_name, COL_FILES, iitem);
          }
        }
      }
//.........这里部分代码省略.........
开发者ID:garfieldchien,项目名称:omnia-projetcs,代码行数:101,代码来源:Files.c

示例14: wceex_stat

/*******************************************************************************
* wceex_stat - Get file attributes for file and store them in buffer.
*
* Description:
*
*   File times on Windows CE: Windows CE object store keeps track of only
*   one time, the time the file was last written to.
*
* Return value:
*
*   Upon successful completion, 0 shall be returned.
*   Otherwise, -1 shall be returned and errno set to indicate the error.
*
*   XXX - mloskot - errno is not yet implemented
*
* Reference:
*   IEEE Std 1003.1, 2004 Edition
*
*******************************************************************************/
int wceex_stat(const char* filename, struct stat *buffer)
{
    HANDLE findhandle;
    WIN32_FIND_DATA findbuf;
    wchar_t pathWCE[MAX_PATH];

    //Don't allow wildcards to be interpreted by system
    if(strpbrk(filename, "?*"))
        //if(wcspbrk(path, L"?*"))
    {
        //errno = ENOENT;
        return(-1);
    }

    //search file/dir
    mbstowcs(pathWCE, filename, strlen(filename) + 1);
    findhandle = FindFirstFile(pathWCE, &findbuf);
    if(findhandle == INVALID_HANDLE_VALUE)
    {
        //is root
        if(_stricmp(filename, ".\\")==0)
        {
            findbuf.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;

            //dummy values
            findbuf.nFileSizeHigh = 0;
            findbuf.nFileSizeLow = 0;
            findbuf.cFileName[0] = '\0';

            buffer->st_mtime = wceex_local_to_time_r(1980 - TM_YEAR_BASE, 0, 1, 0, 0, 0);
            buffer->st_atime = buffer->st_mtime;
            buffer->st_ctime = buffer->st_mtime;
        }

        //treat as an error
        else
        {
            //errno = ENOENT;
            return(-1);
        }
    }
    else
    {
        /* File is found*/

        SYSTEMTIME SystemTime;
        FILETIME LocalFTime;

        //Time of last modification
        if(!FileTimeToLocalFileTime( &findbuf.ftLastWriteTime, &LocalFTime) ||
            !FileTimeToSystemTime(&LocalFTime, &SystemTime))
        {
            //errno = ::GetLastError();
            FindClose( findhandle );
            return( -1 );
        }

        buffer->st_mtime = wceex_local_to_time(&SystemTime);

        //Time od last access of file
        if(findbuf.ftLastAccessTime.dwLowDateTime || findbuf.ftLastAccessTime.dwHighDateTime)
        {
            if(!FileTimeToLocalFileTime(&findbuf.ftLastAccessTime, &LocalFTime) ||
                !FileTimeToSystemTime(&LocalFTime, &SystemTime))
            {
                //errno = ::GetLastError();
                FindClose( findhandle );
                return( -1 );
            }
            buffer->st_atime = wceex_local_to_time(&SystemTime);
        }
        else
        {
            buffer->st_atime = buffer->st_mtime;
        }


        //Time of creation of file
        if(findbuf.ftCreationTime.dwLowDateTime || findbuf.ftCreationTime.dwHighDateTime)
        {
            if(!FileTimeToLocalFileTime(&findbuf.ftCreationTime, &LocalFTime) ||
//.........这里部分代码省略.........
开发者ID:RangelReale,项目名称:sandbox,代码行数:101,代码来源:wce_stat.c

示例15: defined


//.........这里部分代码省略.........
    int rc;

    if ((rc = DosFindNext(dir,
                          &find, sizeof(find),
                          &count)) != 0) {
        //fprintf(stderr, "%d\n\n", rc);
        return -1;
    }
    if (count != 1)
        return -1;
    name = find.achName;
    if (Flags & ffFULLPATH) {
        JoinDirFile(fullpath, Directory, name);
        name = fullpath;
    }
    memset((void *)&t, 0, sizeof(t));
    t.tm_year = find.fdateLastWrite.year + 80;
    t.tm_mon = find.fdateLastWrite.month - 1;
    t.tm_mday = find.fdateLastWrite.day;
    t.tm_hour = find.ftimeLastWrite.hours;
    t.tm_min = find.ftimeLastWrite.minutes;
    t.tm_sec = find.ftimeLastWrite.twosecs * 2; // ugh!
    t.tm_isdst = -1;
    *fi = new FileInfo(name,
                       (find.attrFile & FILE_DIRECTORY) ? fiDIRECTORY : fiFILE,
                       find.cbFile,
                       mktime(&t));

    return 0;
#elif defined(NT) && !defined(USE_DIRENT)
#if defined(USE_VCFIND)
    _finddata_t find;
    char fullpath[MAXPATH];
    char *name;
    struct tm t;
    int rc;

    if ((rc = _findnext(dir,
                        &find)) != 0) {
        // fprintf(stderr, "%d\n\n", rc);
        return -1;
    }

    name = find.name;
    if (Flags & ffFULLPATH) {
        JoinDirFile(fullpath, Directory, name);
        name = fullpath;
    }

    *fi = new FileInfo(name,
                       (find.attrib & _A_SUBDIR) ? fiDIRECTORY : fiFILE,
                       find.size,
                       find.time_create);
    return 0;
#else
    WIN32_FIND_DATA find;
    char fullpath[MAXPATH];
    char *name;
    struct tm t;
    SYSTEMTIME st;
    FILETIME localft;                   // needed for time conversion
    int rc;

    if ((rc = FindNextFile((HANDLE)dir,
                           &find)) != TRUE) {
        //fprintf(stderr, "%d\n\n", rc);
        return -1;
    }

    name = find.cFileName;
    if (Flags & ffFULLPATH) {
        JoinDirFile(fullpath, Directory, name);
        name = fullpath;
    }

    /*
    * since filetime is in UTC format we need to convert it first to
    * localtime and when we have "correct" time we can use it.
    */

    FileTimeToLocalFileTime(&find.ftLastWriteTime, &localft);
    FileTimeToSystemTime(&localft, &st);

    t.tm_year = st.wYear - 1900;
    t.tm_mon = st.wMonth - 1;           // in system time january is 1...
    t.tm_mday = st.wDay;
    t.tm_hour = st.wHour;
    t.tm_min = st.wMinute;
    t.tm_sec = st.wSecond;
    t.tm_isdst = -1;

    *fi = new FileInfo(name,
                       (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? fiDIRECTORY : fiFILE,
                       find.nFileSizeLow,
                       mktime(&t));
    return 0;
#endif
    //    put code here
#endif
}
开发者ID:AaronDP,项目名称:efte_adbshell,代码行数:101,代码来源:s_direct.cpp


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