OSBasics.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #ifdef _WINDOWS
  14. #include <windows.h>
  15. #else
  16. #include <dirent.h>
  17. #include <sys/types.h>s
  18. #include <sys/stat.h>
  19. #endif
  20. #include <vector>
  21. #include <string>
  22. #include "physfs.h"
  23. using namespace std;
  24. class _PolyExport OSFileEntry {
  25. public:
  26. OSFileEntry() {};
  27. OSFileEntry(string path, string name, int type);
  28. string name;
  29. string extension;
  30. string nameWithoutExtension;
  31. string basePath;
  32. string fullPath;
  33. int type;
  34. static const int TYPE_FILE = 0;
  35. static const int TYPE_FOLDER = 1;
  36. };
  37. class _PolyExport OSFILE {
  38. public:
  39. OSFILE(){}
  40. void debugDump();
  41. int fileType;
  42. FILE *file;
  43. PHYSFS_file *physFSFile;
  44. static const int TYPE_FILE = 0;
  45. static const int TYPE_ARCHIVE_FILE = 1;
  46. };
  47. class _PolyExport OSBasics {
  48. public:
  49. static OSFILE *open(string filename, string opts);
  50. static int close(OSFILE *file);
  51. static size_t read( void * ptr, size_t size, size_t count, OSFILE * stream );
  52. static size_t write( const void * ptr, size_t size, size_t count, OSFILE * stream );
  53. static int seek(OSFILE * stream, long int offset, int origin );
  54. static long tell(OSFILE * stream);
  55. static vector<OSFileEntry> parsePhysFSFolder(string pathString, bool showHidden);
  56. static vector<OSFileEntry> parseFolder(string pathString, bool showHidden);
  57. static bool isFolder(string pathString);
  58. static void createFolder(string pathString);
  59. private:
  60. };