OSBasics.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * OSBasics.h
  3. * PolyStudio
  4. *
  5. * Created by Ivan Safrin on 8/4/08.
  6. * Copyright 2008 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package System
  10. #pragma once
  11. #include "PolyLogger.h"
  12. #include "PolyGlobals.h"
  13. #include "PolyString.h"
  14. #ifdef _WINDOWS
  15. #include <windows.h>
  16. #else
  17. #include <dirent.h>
  18. #include <sys/types.h>s
  19. #include <sys/stat.h>
  20. #endif
  21. #include <vector>
  22. #include <string>
  23. #include "physfs.h"
  24. using namespace std;
  25. using namespace Polycode;
  26. class _PolyExport OSFileEntry {
  27. public:
  28. OSFileEntry() {};
  29. OSFileEntry(String path, String name, int type);
  30. String name;
  31. String extension;
  32. String nameWithoutExtension;
  33. String basePath;
  34. String fullPath;
  35. int type;
  36. static const int TYPE_FILE = 0;
  37. static const int TYPE_FOLDER = 1;
  38. };
  39. class _PolyExport OSFILE {
  40. public:
  41. OSFILE(){}
  42. void debugDump();
  43. int fileType;
  44. FILE *file;
  45. PHYSFS_file *physFSFile;
  46. static const int TYPE_FILE = 0;
  47. static const int TYPE_ARCHIVE_FILE = 1;
  48. };
  49. class _PolyExport OSBasics {
  50. public:
  51. static OSFILE *open(String filename, String opts);
  52. static int close(OSFILE *file);
  53. static size_t read( void * ptr, size_t size, size_t count, OSFILE * stream );
  54. static size_t write( const void * ptr, size_t size, size_t count, OSFILE * stream );
  55. static int seek(OSFILE * stream, long int offset, int origin );
  56. static long tell(OSFILE * stream);
  57. static vector<OSFileEntry> parsePhysFSFolder(String pathString, bool showHidden);
  58. static vector<OSFileEntry> parseFolder(String pathString, bool showHidden);
  59. static bool isFolder(String pathString);
  60. static void createFolder(String pathString);
  61. private:
  62. };