winVolume.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _WINVOLUME_H_
  23. #define _WINVOLUME_H_
  24. #ifndef _VOLUME_H_
  25. #include "core/volume.h"
  26. #endif
  27. namespace Torque
  28. {
  29. using namespace FS;
  30. namespace Win32
  31. {
  32. //-----------------------------------------------------------------------------
  33. class Win32FileSystem: public FileSystem
  34. {
  35. public:
  36. Win32FileSystem(String volume);
  37. ~Win32FileSystem();
  38. String getTypeStr() const { return "Win32"; }
  39. FileNodeRef resolve(const Path& path);
  40. FileNodeRef create(const Path& path,FileNode::Mode);
  41. bool remove(const Path& path);
  42. bool rename(const Path& from,const Path& to);
  43. Path mapTo(const Path& path);
  44. Path mapFrom(const Path& path);
  45. private:
  46. String mVolume;
  47. };
  48. //-----------------------------------------------------------------------------
  49. /// Win32 stdio file access.
  50. /// This class makes use the fopen, fread and fwrite for buffered io.
  51. class Win32File: public File
  52. {
  53. public:
  54. ~Win32File();
  55. Path getName() const;
  56. NodeStatus getStatus() const;
  57. bool getAttributes(Attributes*);
  58. U64 getSize();
  59. U32 getPosition();
  60. U32 setPosition(U32,SeekMode);
  61. bool open(AccessMode);
  62. bool close();
  63. U32 read(void* dst, U32 size);
  64. U32 write(const void* src, U32 size);
  65. private:
  66. friend class Win32FileSystem;
  67. U32 calculateChecksum();
  68. Path mPath;
  69. String mName;
  70. void *mHandle;
  71. NodeStatus mStatus;
  72. Win32File(const Path &path, String name);
  73. bool _updateInfo();
  74. void _updateStatus();
  75. };
  76. //-----------------------------------------------------------------------------
  77. class Win32Directory: public Directory
  78. {
  79. public:
  80. ~Win32Directory();
  81. Path getName() const;
  82. NodeStatus getStatus() const;
  83. bool getAttributes(Attributes*);
  84. bool open();
  85. bool close();
  86. bool read(Attributes*);
  87. private:
  88. friend class Win32FileSystem;
  89. U32 calculateChecksum();
  90. Path mPath;
  91. String mName;
  92. void *mHandle;
  93. NodeStatus mStatus;
  94. Win32Directory(const Path &path,String name);
  95. void _updateStatus();
  96. };
  97. } // Namespace
  98. } // Namespace
  99. #endif