#include "filesystem.hpp" #include <dirent.h> #include <unistd.h> char const* sprawl::filesystem::LineSeparator() { return "\n"; } char const* sprawl::filesystem::NullDevice() { return "/dev/null"; } sprawl::collections::Vector<sprawl::String> sprawl::filesystem::ListDir(sprawl::String const& directory) { sprawl::collections::Vector<sprawl::String> out; struct dirent const* entry; DIR* dir; dir = opendir(directory.GetOwned().c_str()); if(dir != nullptr) { entry = readdir(dir); while(entry != nullptr) { if(strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { out.PushBack(entry->d_name); } entry = readdir(dir); } closedir(dir); } return std::move(out); } bool sprawl::filesystem::MakeSymlink(String const& target, String const& link) { return (symlink(target.GetOwned().c_str(), link.GetOwned().c_str()) == 0); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 14822 | ShadauxCat |
Last batch of filesystem code for now, added MakeSymlink and GetPid, removed other todo functions for the time being. Also fixed some bugs: -Linux IsLink() implementation not using lstat = broken -File::IsClosed() would crash if file were created via default constructor or null handle -Remove() and RmDir() on Windows were inconsistent with Linux - in Linux all symlinks are removed with Remove() even if they point to directories. Forced windows to work the same way. -Asked RmTree to please not descend into symbolic links to directories, but just to remove them, thanks. -Removed starting \\?\ from result of RealPath() on Windows -Fixed IsFile() on Windows just not working - assuming anything that's not a directory is a file now. -Fixed StringBuilder only printing the first character if you passed it type char* instead of type char const* #review-14823 |
||
#3 | 14816 | ShadauxCat |
Filled in some more filesystem functions, added appropriate unit tests. Only a few remain. #review-14817 |
||
#2 | 14761 | ShadauxCat |
First drop of code for sprawl::filesystem and sprawl::path. Library will continue to grow. Also fixed a warning on linux. #review-14762 |
||
#1 | 12508 | ShadauxCat |
-Added threading library. Currently only functional for Linux; Windows will fail to link. (I will fix this soon.) -Fixed missing move and copy constructors in List and ForwardList -Fixed broken move constructor in HashMap -Fixed missing const get() in HashMap -Fixed broken operator-> in ListIterator -Added sprawl::noncopyable -Added sketch headers for filesystem library -Made StringLiteral hashable, added special hashes for pointers and integers in murmur3 -Fixed compiler warning in async_network -Updated memory allocators to use new threading library for mutexes -Added accessibility to sprawl::StringLiteral to be able toa ccess its pointer and length and perform pointer comparisons #review-12504 |