Linux下获取文件大小,检索目录函数
来源:互联网 发布:淘宝1.74非球面镜片 编辑:程序博客网 时间:2024/05/22 17:14
http://blog.csdn.net/codeheng/article/details/43766809
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <dirent.h>
- #include <string>
- #include <iostream>
- #define PATH "/media/work/test"
- int main(int argc, char **argv)
- {
- DIR *pDir = opendir(PATH);
- if (pDir == NULL)
- {
- perror("opendir failed.\n");
- }
- struct dirent *pDirent;
- std::string picture("test.cpp");
- std::string str;
- while((pDirent = readdir(pDir)) != NULL)
- {
- //printf("name: %s\n", pDirent->d_name);
- str = pDirent->d_name;
- if (str.find(picture) != str.npos)
- {
- std::cout<<"string name: "<<str<<std::endl;
- break;
- }
- }
- struct stat buf;
- if (stat(str.c_str(), &buf) == -1)
- {
- perror("stat failed.\n");
- }
- std::cout<< "size: "<<buf.st_size<<std::endl;
- std::cout<< "st_mtime: "<<ctime(&buf.st_mtime)<<std::endl;
- return 0;
- }
阅读全文
0 0
- Linux下获取文件大小,检索目录函数
- Linux下获取文件大小,检索目录函数
- linux获取目录下文件大小的问题
- linux下获取文件大小
- Linux:查看目录下文件大小
- Linux 获取文件大小--C函数
- Linux 获取文件大小--C函数
- linux获取文件大小的函数
- Linux 获取文件大小--C函数
- linux下获取文件大小总结
- linux c 下获取文件大小
- linux c 下获取文件大小
- linux c下获取文件大小
- linux 使用lseek函数来获取文件大小
- Linux下获取文件大小的方法
- Linux下获取文件大小的方法
- Linux下获取文件大小的方法
- Linux下获取文件大小的方法
- 公司内部wiki,你建立了么?
- jquery对象怎么转换为html对象(也就是js的dom对象)
- 在windows上 部署 Redis cluster模式的集群服务
- ASP.NET页面传值汇总 (Session / Server.Transfer / Query String / Cookie / Application )
- 2017.06.01回顾
- Linux下获取文件大小,检索目录函数
- DelayedOperation分析
- eclipse 快捷键失效 Ctrl+S Ctrl+F Ctrl+Z
- input子系统基础之按键1——什么是input子系统?
- 两数之和
- c++基础杂记
- php开源项目 http://www.phpky.cn/ [记录]
- windows10 环境下 opencv3.0.0+opencv_contrib重编译
- linux nginx配置https