在Linux上。
我想构建一个文件缓冲区。 每30分钟保存一个新文件。 但允许的文件总数为'n'。
所以当创建'n + 1'文件时,必须删除最旧的文件。
我找到了像'dirent.h'和'struct stat'这样的东西,可以帮助访问目录,列出所有文件并获取其属性。
然而,struct stat不会给出创建时间,但只是 - 上次修改,上次访问,最后一次状态的更改时间http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstat.h.html
请帮忙。
PS:现在无法提升。
On Linux.
I want to build a buffer of files. A new file is saved every 30 minutes . But the total number of files allowed are 'n'.
so when 'n+1'th file is created, the oldest one has to be deleted.
I found stuff like 'dirent.h' and 'struct stat' that can help access directory, list all files and get its properties.
struct stat does not however the give time of creation, but just - last modified,last accessed, time of last status changed http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstat.h.html
Please Help.
P.S: boost is not available right now.
最满意答案
在Linux上,没有文件创建时间与文件系统元数据中的文件一起保存。 有一些接近它,但不一样: inode修改时间 (这是struct stat的st_ctime成员)。 来自stat手册页:
通过写入或通过设置inode信息(即所有者,组组,链接计数,模式等)来更改字段st_ctime。
只要您不修改这些属性并且不向文件写入 (超过零个字节) - st_ctime就是您的“文件创建时间”。
On Linux there is no such thing as file creation time saved with file in file system(s) metadata. There is something close to it, but not the same: inode modification time (this is the st_ctime member of struct stat). From stat man page:
The field st_ctime is changed by writing or by setting inode information (i.e., owner, group group,link count, mode, etc.).
As long as you do not modify these properties and you do not write (more than zero bytes) to a file(s) - the st_ctime is your "file creation time".
有没有办法只使用c ++找到最旧的文件(is there a way to find the oldest file using just the c++)在Linux上。
我想构建一个文件缓冲区。 每30分钟保存一个新文件。 但允许的文件总数为'n'。
所以当创建'n + 1'文件时,必须删除最旧的文件。
我找到了像'dirent.h'和'struct stat'这样的东西,可以帮助访问目录,列出所有文件并获取其属性。
然而,struct stat不会给出创建时间,但只是 - 上次修改,上次访问,最后一次状态的更改时间http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstat.h.html
请帮忙。
PS:现在无法提升。
On Linux.
I want to build a buffer of files. A new file is saved every 30 minutes . But the total number of files allowed are 'n'.
so when 'n+1'th file is created, the oldest one has to be deleted.
I found stuff like 'dirent.h' and 'struct stat' that can help access directory, list all files and get its properties.
struct stat does not however the give time of creation, but just - last modified,last accessed, time of last status changed http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstat.h.html
Please Help.
P.S: boost is not available right now.
最满意答案
在Linux上,没有文件创建时间与文件系统元数据中的文件一起保存。 有一些接近它,但不一样: inode修改时间 (这是struct stat的st_ctime成员)。 来自stat手册页:
通过写入或通过设置inode信息(即所有者,组组,链接计数,模式等)来更改字段st_ctime。
只要您不修改这些属性并且不向文件写入 (超过零个字节) - st_ctime就是您的“文件创建时间”。
On Linux there is no such thing as file creation time saved with file in file system(s) metadata. There is something close to it, but not the same: inode modification time (this is the st_ctime member of struct stat). From stat man page:
The field st_ctime is changed by writing or by setting inode information (i.e., owner, group group,link count, mode, etc.).
As long as you do not modify these properties and you do not write (more than zero bytes) to a file(s) - the st_ctime is your "file creation time".
发布评论