wjakob / filesystem Goto Github PK
View Code? Open in Web Editor NEWA tiny self-contained path manipulation library for C++
License: Other
A tiny self-contained path manipulation library for C++
License: Other
I try to build the library on POSIX environment, where the "MAX_PATH" constant is not defined
make
Scanning dependencies of target path_demo
[ 50%] Building CXX object CMakeFiles/path_demo.dir/path_demo.cpp.o
In file included from /home/boris/src/mygithub/filesystem/path_demo.cpp:2:0:
/home/boris/src/mygithub/filesystem/filesystem/path.h: In member function ‘std::__cxx11::string filesystem::path::str(filesystem::path::path_type) const’:
/home/boris/src/mygithub/filesystem/filesystem/path.h:200:30: error: ‘MAX_PATH’ was not declared in this scope
if (length > MAX_PATH)
^~~~~~~~
/home/boris/src/mygithub/filesystem/filesystem/path.h:200:30: note: suggested alternative: ‘_CS_PATH’
if (length > MAX_PATH)
^~~~~~~~
_CS_PATH
CMakeFiles/path_demo.dir/build.make:62: recipe for target 'CMakeFiles/path_demo.dir/path_demo.cpp.o' failed
make[2]: *** [CMakeFiles/path_demo.dir/path_demo.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/path_demo.dir/all' failed
make[1]: *** [CMakeFiles/path_demo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
the api
bool resize_file(size_t target_length)
, should change to
bool resize_file(uint64_t target_length)
to support large file that filesize more than 4GB
create_directories should be called recursively if the parent directory isn't present. Currently create_directory is called, which gives you two levels of directory but not more.
I really want to use the library; but my target is MSVC 2010 and average OS X and Linux. Not everyone has the most recent compilers, especially people installing stuff through package managers :)
You can gracefully degrade code using __cplusplus
:
I also don't want to use bloated boost
in some situations. your code provided a good choice. But can you add the directory_iterator
similar boost
? I think it's very useful at some times.
first thanks for your code.
in work we use need delete directory file and create directory file recursively .
can you consider add them.
base create_directory in you work.
i and some function but not consider cross platform.
inline bool create_directory_deep(const path& p ) {
if (p.exists()){
return TRUE;
}
path pathParent = p.parent_path();
if (create_directory_deep(pathParent)){
if (p.empty()) return TRUE;
int ret = create_directory(p);
return ret;
//return create_directory(p);
}
else{
false;
}
return TRUE;
}
inline void getAllFiles(string path, vector& files)
{
long hFile = 0;
struct _finddata_t fileinfo;
string p;
if ((hFile = _findfirst(p.assign(path).append("\*").c_str(), &fileinfo)) != -1)
{
do
{
if ((fileinfo.attrib & _A_SUBDIR))
{
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
{
// no director return
//files.push_back(p.assign(path).append("/").append(fileinfo.name));
getAllFiles(p.assign(path).append("/").append(fileinfo.name), files);
}
}
else
{
files.push_back(p.assign(path).append("/").append(fileinfo.name));
}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
Hi Wenzel,
Is it possible to use Wenzel::filesystem replace the filesystem to avoid the ambiguity?
Best
Ziqi Wang
Running path(executable).exists()
correctly returns true if the executable is there.
However, doing a path(executable).is_file()
returns false, which not very intuitive to me. This happens because in the is_file call (on windows), the attribute "FILE_ATTRIBUTE_ARCHIVE" is set, but not the attribute "FILE_ATTRIBUTE_NORMAL".
When file doesn't exist, file_size() method will block program.
I don't want to violate your copyright, but the chances I remember to put your information in my documetnation when I'm done seems low...
Would you be willing to BSD this library?
The reason is that realpath
only works on existing files... so if I want to get the absolute path of a file or directory I'm about to create, it will throw an exception (Internal error in realpath(): No such file or directory)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.