#include "filesystem.hpp" #include "path.hpp" #include <Windows.h> char const* sprawl::filesystem::LineSeparator() { return "\r\n"; } char const* sprawl::filesystem::NullDevice() { return "NUL"; } sprawl::collections::Vector<sprawl::String> sprawl::filesystem::ListDir(sprawl::String const& directory) { collections::Vector<String> out; WIN32_FIND_DATA ffd; HANDLE handle = INVALID_HANDLE_VALUE; sprawl::String dirLocal; char c = directory[directory.length() - 1]; if (c != path::Separator() && c != path::AltSeparator()) { dirLocal = Format("{}{}*", directory, path::Separator()); } else { dirLocal = Format("{}*", directory); } handle = FindFirstFileA(dirLocal.c_str(), &ffd); if (handle == INVALID_HANDLE_VALUE) { return std::move(out); } do { if (strcmp(ffd.cFileName, ".") != 0 && strcmp(ffd.cFileName, "..") != 0) { out.PushBack(ffd.cFileName); } } while (FindNextFile(handle, &ffd) != 0); FindClose(handle); return std::move(out); } bool sprawl::filesystem::MakeSymlink(String const& target, String const& link) { return CreateSymbolicLinkA(link.GetOwned().c_str(), target.GetOwned().c_str(), path::IsDirectory(target) ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 23398 | ququlala | "Forking branch Mainline of shadauxcat-libsprawl to ququlala-libsprawl." | ||
//guest/ShadauxCat/Sprawl/Mainline/filesystem/filesystem_windows.cpp | |||||
#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 |