Qt下如何修改文件的时间(全平台修改)

提供一个全平台修改文件的时间的方法,希望大家喜欢

/* UTIME.C: This program uses _utime to set the
 * file-modification time to the current time.
 * utime.c is a file you should change it by yourself
 */
 
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#ifdef WIN32
#include <sys/utime.h>
#define SHOWCMD "dir utime.c"
#else
#define _utime utime
#define _utimbuf utimbuf
#include <utime.h>
#define SHOWCMD "ls -l utime.c"
#endif
 
void main( void )
{
   /* Show file time before and after. */
   system( SHOWCMD );
   if( _utime( "utime.c", NULL ) == -1 )
      perror( "_utime failed\n" );
   else
      printf( "File time modified\n" );
   system( SHOWCMD );
}

http://www.heilqt.com/topic/556ea6e10654374f37a52a15

posted @ 2016-06-10 17:19  findumars  Views(2139)  Comments(0Edit  收藏  举报