s*****c 发帖数: 753 | 1 Hi, I need to list all files under a directory in C++. How do I achieve
this. I checked and there seems to be direct.h under windows and unistd.h
under linux that provide some operation on the file system. But I fail to
see any function that provide this capability. Anything that I missed? Or
should I have to perform a system call to invoke "dir abc*" or "ls abc*"? |
t****t 发帖数: 6806 | 2 you may use opendir() family function, which is specified in POSIX.1-2001.
【在 s*****c 的大作中提到】 : Hi, I need to list all files under a directory in C++. How do I achieve : this. I checked and there seems to be direct.h under windows and unistd.h : under linux that provide some operation on the file system. But I fail to : see any function that provide this capability. Anything that I missed? Or : should I have to perform a system call to invoke "dir abc*" or "ls abc*"?
|
s*****c 发帖数: 753 | 3 Thanks alot, this is helpful. So I can use this under linux.
Is there solutions under windows? I don't want to use boost library since
what I am trying to implement is some extra feature. I don't want to drag
in a third party library for this. Also I don't want to use MSDN's
FindNextFile() since it will use windows.h, and will add dependencies.
If there are no better solutions, I think I would rather do a system("dir
abc* >output.txt") and then check the content of the output.txt.
【在 t****t 的大作中提到】 : you may use opendir() family function, which is specified in POSIX.1-2001.
|
r*********r 发帖数: 3195 | 4 use filesystem library in boost. |