Android C++系列:Linux常用函数和工具

1. 时间函数

1.1 文件访问时间

#include <sys/types.h>
#include <utime.h>
int utime (const char *name, const struct utimebuf *t); 
返回:若成功则为 0,若出错则为- 1

如果times是一个空指针,则存取时间和修改时间两者都设置为当前时间;

如果times是非空指针,则存取时间和修改时间被设置为 times所指向的结构中的值。此 时,进程的有效用户ID必须等于该文件的所有者 ID,或者进程必须是一个超级用户进程。对 文件只具有写许可权是不够的

此函数所使用的结构是:

struct utimbuf {
time_t actime; /*access time*/ 
time_t modtime; /*modification time*/ }

1.2 cpu使用时间

#include <sys/time.h> 
#include <sys/resource.h>
int getrusage(int who, struct rusage *usage);
  • RUSAGE_SELF:Return resource usage statistics for the calling process, which is the sum of resources used by all threads in the process.

  • RUSAGE_CHILDREN:Return resource usage statistics for all children of the calling process that have terminated and been wait

相关推荐

  1. Android C++系列Linux函数工具

    2024-07-09 17:08:04       21 阅读
  2. android 工具

    2024-07-09 17:08:04       21 阅读
  3. Android init调试工具

    2024-07-09 17:08:04       17 阅读
  4. Android JNIAPI函数介绍

    2024-07-09 17:08:04       37 阅读
  5. 【运维】Linux 网络工具

    2024-07-09 17:08:04       34 阅读
  6. 实用工具系列-git命令

    2024-07-09 17:08:04       53 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 17:08:04       50 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 17:08:04       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 17:08:04       43 阅读
  4. Python语言-面向对象

    2024-07-09 17:08:04       54 阅读

热门阅读

  1. vb.net读取mssql的image字段后,如何转换成二进制

    2024-07-09 17:08:04       24 阅读
  2. 常用 Android 反编译工具apktooldex2jarenjarifyjd-guijadx

    2024-07-09 17:08:04       20 阅读
  3. Android Gradle 开发与应用 (十): Gradle 脚本最佳实践

    2024-07-09 17:08:04       26 阅读
  4. 牛客周赛 Round 50

    2024-07-09 17:08:04       34 阅读
  5. 量化机器人如何提高投资效率?

    2024-07-09 17:08:04       24 阅读
  6. Emacs相关

    2024-07-09 17:08:04       27 阅读
  7. 细水长流:SKlearn中模型的增量训练实践

    2024-07-09 17:08:04       26 阅读
  8. 论如何搭建属于自己的服务器?

    2024-07-09 17:08:04       18 阅读
  9. RabbitMQ实现延迟消息

    2024-07-09 17:08:04       44 阅读
  10. 【数据挖掘】银行信用卡风险大数据分析与挖掘

    2024-07-09 17:08:04       19 阅读
  11. emacs 重新加载磁盘上的文件

    2024-07-09 17:08:04       22 阅读
  12. Linux学习笔记(一)

    2024-07-09 17:08:04       26 阅读