main.bmx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. ' Copyright (c) 2007-2019 Bruce A Henderson
  2. '
  3. ' Permission is hereby granted, free of charge, to any person obtaining a copy
  4. ' of this software and associated documentation files (the "Software"), to deal
  5. ' in the Software without restriction, including without limitation the rights
  6. ' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. ' copies of the Software, and to permit persons to whom the Software is
  8. ' furnished to do so, subject to the following conditions:
  9. '
  10. ' The above copyright notice and this permission notice shall be included in
  11. ' all copies or substantial portions of the Software.
  12. '
  13. ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. ' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. ' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. ' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. ' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. ' THE SOFTWARE.
  20. '
  21. SuperStrict
  22. Import BRL.LinkedList
  23. Global volume_driver:TVolume
  24. Rem
  25. bbdoc: A system Volume
  26. End Rem
  27. Type TVolume
  28. Rem
  29. bbdoc: True if available, false if not.
  30. End Rem
  31. Field available:Int
  32. Rem
  33. bbdoc: The volume name.
  34. End Rem
  35. Field volumeName:String
  36. Rem
  37. bbdoc: The device name
  38. End Rem
  39. Field volumeDevice:String
  40. Rem
  41. bbdoc: The system type.
  42. End Rem
  43. Field volumeType:String
  44. Rem
  45. bbdoc: Cached volume size (in bytes)
  46. about: For the current size, #Refresh first.
  47. End Rem
  48. Field volumeSize:Long
  49. Rem
  50. bbdoc: Cached free space (in bytes)
  51. about: For the current free space, #Refresh first.
  52. End Rem
  53. Field volumeFree:Long
  54. Rem
  55. bbdoc: Refreshes size/free info for the volume.
  56. End Rem
  57. Method Refresh() Abstract
  58. ' platform specific implementations
  59. Method ListVolumes:TList() Abstract
  60. Method GetVolumeFreeSpace:Long(vol:String) Abstract
  61. Method GetVolumeSize:Long(vol:String) Abstract
  62. Method GetVolumeInfo:TVolume(vol:String) Abstract
  63. Method GetUserHomeDir:String() Abstract
  64. Method GetUserDesktopDir:String() Abstract
  65. Method GetUserAppDir:String() Abstract
  66. Method GetUserDocumentsDir:String() Abstract
  67. Method GetCustomDir:String(dirType:Int, flags:Int = 0) Abstract
  68. End Type
  69. Rem
  70. bbdoc: Returns a list of volumes on the system.
  71. End Rem
  72. Function ListVolumes:TList()
  73. Return volume_driver.ListVolumes()
  74. End Function
  75. Rem
  76. bbdoc: Returns the amount of free space (in bytes) on the given volume.
  77. about: Parameters:
  78. <ul>
  79. <li><b>vol</b> : the name of the volume</li>
  80. </ul>
  81. End Rem
  82. Function GetVolumeFreeSpace:Long(vol:String)
  83. Return volume_driver.GetVolumeFreeSpace(vol)
  84. End Function
  85. Rem
  86. bbdoc: Returns the size (in bytes) of the given volume.
  87. about: Parameters:
  88. <ul>
  89. <li><b>vol</b> : the name of the volume</li>
  90. </ul>
  91. End Rem
  92. Function GetVolumeSize:Long(vol:String)
  93. Return volume_driver.GetVolumeSize(vol)
  94. End Function
  95. Rem
  96. bbdoc: Populates and returns a #TVolume object.
  97. about: Parameters:
  98. <ul>
  99. <li><b>vol</b> : the name of the volume</li>
  100. </ul>
  101. End Rem
  102. Function GetVolumeInfo:TVolume(vol:String)
  103. Return volume_driver.GetVolumeInfo(vol)
  104. End Function
  105. Rem
  106. bbdoc: Returns the user home directory.
  107. about: The table lists examples for the various platforms -
  108. <table align="center">
  109. <tr><th>Platform</th><th>Example</th><th>Equivalent</th></tr>
  110. <tr><td>Linux</td><td>`/home/username`</td><td>`~`</td></tr>
  111. <tr><td>Mac OS</td><td>`/Users/username`</td><td>`~`</td></tr>
  112. <tr><td>Win32</td><td>`C:\Documents and Settings\username`</td><td>&nbsp;</td></tr>
  113. </table>
  114. End Rem
  115. Function GetUserHomeDir:String()
  116. Return volume_driver.GetUserHomeDir()
  117. End Function
  118. Rem
  119. bbdoc: Returns the user Desktop directory.
  120. about: The table lists examples for the various platforms -
  121. <table align="center">
  122. <tr><th>Platform</th><th>Example</th><th>Equivalent</th></tr>
  123. <tr><td>Linux</td><td>`/home/username/Desktop`</td><td>`~/Desktop`</td></tr>
  124. <tr><td>Mac OS</td><td>`/Users/username/Desktop`</td><td>`~/Desktop`</td></tr>
  125. <tr><td>Win32</td><td>`C:\Documents and Settings\username\Desktop`</td><td>&nbsp;</td></tr>
  126. </table>
  127. End Rem
  128. Function GetUserDesktopDir:String()
  129. Return volume_driver.GetUserDesktopDir()
  130. End Function
  131. Rem
  132. bbdoc: Returns the user directory for application data.
  133. about: The table lists examples for the various platforms -
  134. <table align="center">
  135. <tr><th>Platform</th><th>Example</th><th>Equivalent</th></tr>
  136. <tr><td>Linux</td><td>`/home/username`</td><td>`~`</td></tr>
  137. <tr><td>Mac OS</td><td>`/Users/username/Library/Application Support`</td><td>`~/Library/Application Support`</td></tr>
  138. <tr><td>Win32</td><td>`C:\Documents and Settings\username\Application Data`</td><td>&nbsp;</td></tr>
  139. </table>
  140. End Rem
  141. Function GetUserAppDir:String()
  142. Return volume_driver.GetUserAppDir()
  143. End Function
  144. Rem
  145. bbdoc: Returns the user Documents directory.
  146. about: The table lists examples for the various platforms -
  147. <table align="center">
  148. <tr><th>Platform</th><th>Example</th><th>Equivalent</th></tr>
  149. <tr><td>Linux</td><td>`/home/username/Documents`</td><td>`~/Documents`</td></tr>
  150. <tr><td>Mac OS</td><td>`/Users/username/Documents`</td><td>`~/Documents`</td></tr>
  151. <tr><td>Win32</td><td>`C:\Documents and Settings\username\My Documents`</td><td>&nbsp;</td></tr>
  152. </table>
  153. End Rem
  154. Function GetUserDocumentsDir:String()
  155. Return volume_driver.GetUserDocumentsDir()
  156. End Function
  157. Rem
  158. bbdoc: Returns the custom directory path.
  159. about: The following table lists valid @dirType -
  160. <table align="center">
  161. <tr><th>Platform</th><th>dirType</th><th>Description</th></tr>
  162. <tr><td>Mac, Linux</td><td>DT_SHAREDUSERDATA</td><td>The Shared documents folder.</td></tr>
  163. <tr><td>All</td><td>DT_USERPICTURES</td><td>The &quot;Pictures&quot; or &quot;My Pictures&quot; folder of the user.</td></tr>
  164. <tr><td>All</td><td>DT_USERMUSIC</td><td>The &quot;Music&quot; or &quot;My Music&quot; folder of the user.</td></tr>
  165. <tr><td>All</td><td>DT_USERMOVIES</td><td>The &quot;Movies&quot;, &quot;Videos&quot; or &quot;My Videos&quot; folder of the user.</td></tr>
  166. <tr><td>Win32</td><td>CSIDL_xxxxxxxx</td><td>Any of the Windows-specific CSIDL identifiers that represent different folders on the system.</td></tr>
  167. </table>
  168. <p>Returns Null if @dirType is not valid for the platform.</p>
  169. End Rem
  170. Function GetCustomDir:String(dirType:Int, flags:Int = 0)
  171. Return volume_driver.GetCustomDir(dirType, flags)
  172. End Function
  173. ' custom dir types
  174. Const DT_SHAREDUSERDATA:Int = -1
  175. Const DT_USERPICTURES:Int = -2
  176. Const DT_USERMUSIC:Int = -3
  177. Const DT_USERMOVIES:Int = -4