FileSystem.pkg 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. $#include "FileSystem.h"
  2. static const unsigned SCAN_FILES;
  3. static const unsigned SCAN_DIRS;
  4. static const unsigned SCAN_HIDDEN;
  5. class FileSystem : public Object
  6. {
  7. bool SetCurrentDir(const String pathName);
  8. bool CreateDir(const String pathName);
  9. int SystemCommand(const String commandLine);
  10. // int SystemRun(const String fileName, const Vector<String>& arguments);
  11. bool SystemOpen(const String fileName, const String mode = String::EMPTY);
  12. bool Copy(const String srcFileName, const String destFileName);
  13. bool Rename(const String srcFileName, const String destFileName);
  14. bool Delete(const String fileName);
  15. void RegisterPath(const String pathName);
  16. String GetCurrentDir() const;
  17. bool HasRegisteredPaths() const;
  18. bool CheckAccess(const String pathName) const;
  19. unsigned GetLastModifiedTime(const String fileName) const;
  20. bool FileExists(const String fileName) const;
  21. bool DirExists(const String pathName) const;
  22. Vector<String> ScanDir(const String pathName, const String filter, unsigned flags, bool recursive) const;
  23. String GetProgramDir() const;
  24. String GetUserDocumentsDir() const;
  25. };
  26. String GetPath(const String fullPath);
  27. String GetFileName(const String fullPath);
  28. String GetExtension(const String fullPath, bool lowercaseExtension = true);
  29. String GetFileNameAndExtension(const String fullPath, bool lowercaseExtension = false);
  30. String ReplaceExtension(const String fullPath, const String newExtension);
  31. String AddTrailingSlash(const String pathName);
  32. String RemoveTrailingSlash(const String pathName);
  33. String GetParentPath(const String pathName);
  34. String GetInternalPath(const String pathName);
  35. String GetNativePath(const String pathName);
  36. bool IsAbsolutePath(const String pathName);
  37. ${
  38. #define TOLUA_DISABLE_tolua_IOLuaAPI_FileSystem_ScanDir00
  39. static int tolua_IOLuaAPI_FileSystem_ScanDir00(lua_State* tolua_S)
  40. {
  41. #ifndef TOLUA_RELEASE
  42. tolua_Error tolua_err;
  43. if (
  44. !tolua_isusertype(tolua_S,1,"const FileSystem",0,&tolua_err) ||
  45. !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
  46. !tolua_isurho3dstring(tolua_S,3,0,&tolua_err) ||
  47. !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
  48. !tolua_isboolean(tolua_S,5,0,&tolua_err) ||
  49. !tolua_isnoobj(tolua_S,6,&tolua_err)
  50. )
  51. goto tolua_lerror;
  52. else
  53. #endif
  54. {
  55. const FileSystem* self = (const FileSystem*) tolua_tousertype(tolua_S,1,0);
  56. const String pathName = ((const String) tolua_tourho3dstring(tolua_S,2,0));
  57. const String filter = ((const String) tolua_tourho3dstring(tolua_S,3,0));
  58. unsigned flags = ((unsigned) tolua_tonumber(tolua_S,4,0));
  59. bool recursive = ((bool) tolua_toboolean(tolua_S,5,0));
  60. #ifndef TOLUA_RELEASE
  61. if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ScanDir'", NULL);
  62. #endif
  63. {
  64. Vector<String> tolua_ret;
  65. self->ScanDir(tolua_ret, pathName,filter,flags,recursive);
  66. tolua_pushurho3dstringvector(tolua_S, tolua_ret);
  67. }
  68. }
  69. return 1;
  70. #ifndef TOLUA_RELEASE
  71. tolua_lerror:
  72. tolua_error(tolua_S,"#ferror in function 'ScanDir'.",&tolua_err);
  73. return 0;
  74. #endif
  75. }
  76. $}