Filesystem.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (C) 2009-2015, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include "anki/util/String.h"
  7. namespace anki {
  8. /// @addtogroup util_file
  9. /// @{
  10. /// Return true if a file exists
  11. Bool fileExists(const CString& filename);
  12. /// Get file extension.
  13. void getFileExtension(
  14. const CString& filename,
  15. GenericMemoryPoolAllocator<U8> alloc,
  16. String& out);
  17. /// Return true if directory exists?
  18. Bool directoryExists(const CString& dir);
  19. /// Callback for the @ref walkDirectoryTree.
  20. /// - 1st parameter: The file or directory name.
  21. /// - 2nd parameter: User data passed to walkDirectoryTree.
  22. /// - 3rd parameter: True if it's directory, false if it's regular file.
  23. using WalkDirectoryTreeCallback = Error(*)(const CString&, void*, Bool);
  24. /// Walk a directory and it's subdirectories. Will walk and list all
  25. /// directories and files of a directory.
  26. ANKI_USE_RESULT Error walkDirectoryTree(
  27. const CString& dir,
  28. void* userData,
  29. WalkDirectoryTreeCallback callback);
  30. /// Equivalent to: rm -rf dir
  31. ANKI_USE_RESULT Error removeDirectory(const CString& dir);
  32. /// Equivalent to: mkdir dir
  33. ANKI_USE_RESULT Error createDirectory(const CString& dir);
  34. /// Get the home directory.
  35. /// Write the home directory to @a buff. The @a buffSize is the size of the
  36. /// @a buff. If the @buffSize is not enough the function will throw
  37. /// an exception.
  38. ANKI_USE_RESULT Error getHomeDirectory(
  39. GenericMemoryPoolAllocator<U8> alloc, String& out);
  40. /// @}
  41. } // end namespace anki