Filesystem.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (C) 2009-2016, 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. {
  9. /// @addtogroup util_file
  10. /// @{
  11. /// Return true if a file exists
  12. Bool fileExists(const CString& filename);
  13. /// Get file extension.
  14. void getFileExtension(
  15. const CString& filename, GenericMemoryPoolAllocator<U8> alloc, String& out);
  16. /// Return true if directory exists?
  17. Bool directoryExists(const CString& dir);
  18. /// Callback for the @ref walkDirectoryTree.
  19. /// - 1st parameter: The file or directory name.
  20. /// - 2nd parameter: User data passed to walkDirectoryTree.
  21. /// - 3rd parameter: True if it's directory, false if it's regular file.
  22. using WalkDirectoryTreeCallback = Error (*)(const CString&, void*, Bool);
  23. /// Walk a directory and it's subdirectories. Will walk and list all
  24. /// directories and files of a directory.
  25. ANKI_USE_RESULT Error walkDirectoryTree(
  26. const CString& dir, void* userData, WalkDirectoryTreeCallback callback);
  27. /// Equivalent to: rm -rf dir
  28. ANKI_USE_RESULT Error removeDirectory(const CString& dir);
  29. /// Equivalent to: mkdir dir
  30. ANKI_USE_RESULT Error createDirectory(const CString& dir);
  31. /// Get the home directory.
  32. /// Write the home directory to @a buff. The @a buffSize is the size of the
  33. /// @a buff. If the @buffSize is not enough the function will throw
  34. /// an exception.
  35. ANKI_USE_RESULT Error getHomeDirectory(
  36. GenericMemoryPoolAllocator<U8> alloc, String& out);
  37. /// @}
  38. } // end namespace anki