windows调用的是_stat函数,linux调用的是stat函数。

#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h> int main( void )
{
int result;
char* filename = "putty.exe";
//errno_t err;
#ifdef WIN32
struct _stat buf;
result = _stat( filename, &buf );
#else
struct stat buf;
result = stat(filename, &buf);
#endif if( result != )
{
perror( "Problem getting information" );
switch (errno)
{
case ENOENT:
printf("File %s not found.\n", filename);
break;
case EINVAL:
printf("Invalid parameter to _stat.\n");
break;
default:
/* Should never be reached. */
printf("Unexpected error in _stat.\n");
}
}
else
{
// Output some of the statistics:
printf( "File size : %ld\n", buf.st_size );
printf( "Drive : %c:\n", buf.st_dev + 'A' ); time_t t;
tzset(); /*tzset()*/
t = time(NULL);
if((t - buf.st_mtime) > )//604800是7天的秒数,下面是删除超过7天的文件
{
remove(filename);
printf("remove file : %s \n" ,filename);
} } }

最新文章

  1. [转]金融业容灾技术分析 (终于看到QREP了)
  2. iOS开发工程师面试题(二)
  3. 精品干货丨APP常用导航框架
  4. 孙鑫MFC学习笔记1.Windows应用程序运行机理
  5. UVa 10810 - Ultra-QuickSort
  6. 设置VMWARE通过桥接方式使用主机网卡上网
  7. uva - 133 The Dole Queue(成环状态下的循环走步方法)
  8. 上传代码到cocoapod ,自己的框架提供给开发者使用
  9. PHP学习笔记五【方法】
  10. SQL点滴14—编辑数据
  11. ogg 初始化
  12. Codeforces Good Bye 2016 题解
  13. C3制作导航栏分割线及立体风格
  14. javascript的数组之map()
  15. neo4j通过LOAD CSV导入结点和关系
  16. Deep Learning中的Large Batch Training相关理论与实践
  17. linux目录文件及系统启动知识
  18. 2019.02.14 codechef Chef at the Food Fair(线段树+泰勒展开)
  19. dup,dup2函数【转】
  20. Java字节流与字符流

热门文章

  1. 生成随机字符串(UUID方法)
  2. GC日志补充
  3. EF迁移
  4. 页面有什么隐藏bug:字体,图片
  5. javascript实现暂停
  6. 修正 phpcmsv9 VIP过期日期为1970
  7. Delphi通过Map文件查找内存地址出错代码所在行
  8. Oracle分区表做跨分区查询
  9. gridView AspNetPager 翻页时 弹出窗体关闭报错
  10. 后台启动mysql ,redis