WIN32_FIND_DATA equivalent in Linux C++
WIN32_FIND_DATA equivalent in Linux C++
Linux C++ 中WIN32_FIND_DATA的等价物是什么?
WIN32_FIND_DATA fileInfo;
WIN32_FIND_DATA是 Windows 规范的数据类型。
当我用 C++11 切换到 Linux Centos 7 时,我需要找到与它等效的,因为WIN32_FIND_DATA有几种方法在 Linux 中不支持。
fileInfo.cFileName
C++17 有filesystem
。
例:
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
fs::path p { "/usr/lib/" };
for (auto& entry : p)
{
// do something with entry
}
return 0;
}
它基于 Boost 库中的文件系统功能,因此您可以将其与较旧的编译器一起使用。
定义为:
(最接近您需要的)结构stat
结构体
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for file system I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};
否则你必须从头开始构建它,GNU Core Utils可以提供帮助。
相关文章:
- 在C++/Linux中设置单调时钟的一些技巧
- Linux的Cpp上的计时器
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 在Linux中哪里可以找到互斥、未来等的源代码
- 如何在linux终端中同时编译和运行c++代码
- 在Linux for Windows上编译C++代码时出错
- 如何找到锁定Linux futex的C++行
- 在linux上调试巨大的C++项目
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- c++方法参数只能在linux的发布模式下自行更改
- 在Linux和C++中的Windows上,散列字符串值会产生不同的输出
- 这里在 Linux 中具有"CreatePipe"和"CreateProcessW"功能吗?
- 函数在Windows或Linux上运行时表现不同
- 在Linux下捕获SIGKILL的C++程序
- 在为LINUX创建共享库时,如何避免STL的私有/弱副本
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- 如何在CPP中创建应该在Windows和Linux上运行的套接字?
- mysql C++ connector [mysql-connector-c++-8.0.19-linux-glibc2
- 这些是什么样的错误?即使我不在 Linux 上工作,我也遇到了 Linux 错误
- CMake WxWidgets项目成功地在Linux上构建,但没有在Windows上构建