winVolume.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. void verifyCompatibility(const Path& _path, WIN32_FIND_DATAW _info);
  41. FileNodeRef create(const Path& path,FileNode::Mode);
  42. bool remove(const Path& path);
  43. bool rename(const Path& from,const Path& to);
  44. Path mapTo(const Path& path);
  45. Path mapFrom(const Path& path);
  46. private:
  47. String mVolume;
  48. };
  49. //-----------------------------------------------------------------------------
  50. /// Win32 stdio file access.
  51. /// This class makes use the fopen, fread and fwrite for buffered io.
  52. class Win32File: public File
  53. {
  54. public:
  55. ~Win32File();
  56. Path getName() const;
  57. NodeStatus getStatus() const;
  58. bool getAttributes(Attributes*);
  59. U64 getSize();
  60. U32 getPosition();
  61. U32 setPosition(U32,SeekMode);
  62. bool open(AccessMode);
  63. bool close();
  64. U32 read(void* dst, U32 size);
  65. U32 write(const void* src, U32 size);
  66. private:
  67. friend class Win32FileSystem;
  68. U32 calculateChecksum();
  69. Path mPath;
  70. String mName;
  71. void *mHandle;
  72. NodeStatus mStatus;
  73. Win32File(const Path &path, String name);
  74. bool _updateInfo();
  75. void _updateStatus();
  76. };
  77. //-----------------------------------------------------------------------------
  78. class Win32Directory: public Directory
  79. {
  80. public:
  81. ~Win32Directory();
  82. Path getName() const;
  83. NodeStatus getStatus() const;
  84. bool getAttributes(Attributes*);
  85. bool open();
  86. bool close();
  87. bool read(Attributes*);
  88. private:
  89. friend class Win32FileSystem;
  90. U32 calculateChecksum();
  91. Path mPath;
  92. String mName;
  93. void *mHandle;
  94. NodeStatus mStatus;
  95. Win32Directory(const Path &path,String name);
  96. void _updateStatus();
  97. };
  98. } // Namespace
  99. } // Namespace
  100. #endif