linux API
班公湖里洗过脚
上马击狂胡,下马草军书
展开
-
linux下获取当前目录
http://blog.csdn.net/abcpanpeng/article/details/64403701. 取得当前工作目录(相当于windows下的GetCurrentDirectory): #include "stdio.h" #include "stdlib.h" #include "string.h" #include "unistd.h"转载 2017-06-01 15:22:31 · 886 阅读 · 0 评论 -
Linux下获取用户主目录的方法
http://www.linuxidc.com/Linux/2011-02/32749.htmLinux下一般把程序的相关配置文件放到用户的主目录下,这样就要求程序得获取当前用户的主目录路径.方法如下char *path = getenv("HOME");printf("path = %s\n",path);getenv是标准库函数,包含stdlib.h转载 2017-06-01 15:24:32 · 15898 阅读 · 0 评论 -
Linux获取当前用户信息函数
http://www.cnblogs.com/dirt2/p/5999842.html转自:http://net.pku.edu.cn/~yhf/linux_c/function/07.html endgrent(关闭组文件)相关函数getgrent,setgrent表头文件转载 2017-06-01 15:26:34 · 1431 阅读 · 0 评论 -
linux下获取磁盘的总空间大小和可用空间大小
http://blog.chinaunix.net/uid-25695950-id-3976199.html方法一:使用命令df方法二:使用函数statfs()功能描述: 查询文件系统相关的信息。 用法: #include /* 或者 */ int statfs(const char *path, struct statfs *buf);转载 2017-06-01 15:28:47 · 1176 阅读 · 0 评论 -
mac下获取磁盘的总空间大小和可用空间大小
#include #include int statfs(constchar *path,struct statfs*buf);int fstatfs(intfd, structstatfs *buf);struct statfs { /* when _DARWIN_FEATURE_64_BIT_INODE is NOT defined */转载 2017-06-01 16:00:38 · 3299 阅读 · 0 评论 -
Linux获取当前时间
http://www.cnblogs.com/fnlingnzb-learner/p/5985822.html代码(可以把clock_gettime换成time(NULL))1 void getNowTime()2 {3 timespec time;4 clock_gettime(CLOCK_REALTIME, &time); //获取相对于1970到现转载 2017-06-06 09:41:10 · 623 阅读 · 0 评论 -
Linux下的C++程序:统计一个目录及其内部文件总共占据的空间大小
https://my.oschina.net/Tsybius2014/blog/330628摘要: Linux下的C++程序:统计一个目录及其内部文件总共占据的空间大小统计一个目录的大小(byte数),最简单的办法是在控制台输入命令:du -sb 目录地址用C++实现这个功能,是通过递归遍历目录下的文件和子目录达到的。需要注意的是,因为Byte数过大,单用一个整型统转载 2017-06-01 17:17:16 · 2600 阅读 · 0 评论 -
Linux C++获取文件夹大小
http://www.cnblogs.com/emituofo/p/6225403.html项目中要计算指定文件夹的大小。百度查到这篇文章,https://my.oschina.net/Tsybius2014/blog/330628方法可行,运行正确。拿到我们的项目中,却遇到一些问题:程序中一些读文件的代码,开始报异常,都不到文件。这些都是以前没有遇到过的问题。到底转载 2017-06-01 17:19:01 · 3364 阅读 · 0 评论 -
Linux下获取文件大小,检索目录函数
http://blog.csdn.net/codeheng/article/details/43766809#include #include #include #include #include #include #include #include #include #define PATH "/me转载 2017-06-01 17:20:18 · 992 阅读 · 0 评论