File: wx.FileSystem.txt

package info (click to toggle)
wxpython4.0 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 211,112 kB
  • sloc: cpp: 888,355; python: 223,130; makefile: 52,087; ansic: 45,780; sh: 3,012; xml: 1,534; perl: 264
file content (439 lines) | stat: -rw-r--r-- 11,053 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.FileSystem:

==========================================================================================================================================
|phoenix_title|  **wx.FileSystem**
==========================================================================================================================================

This class provides an interface for opening files on different file systems.          

It can handle absolute and/or local filenames. 

It uses a system of handlers (see :ref:`wx.FileSystemHandler`) to provide access to user-defined virtual file systems. 







         



.. seealso:: :ref:`wx.FileSystemHandler`, :ref:`wx.FSFile`, :ref:`FileSystem Overview <filesystem overview>`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>FileSystem</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.FileSystem_inheritance.png" alt="Inheritance diagram of FileSystem" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Object.html" title="wx.Object" alt="" coords="19,5,100,35"/> <area shape="rect" id="node2" href="wx.FileSystem.html" title="wx.FileSystem" alt="" coords="5,83,115,112"/> </map> 
   </p>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.FileSystem.__init__`                                                  Constructor.
:meth:`~wx.FileSystem.AddHandler`                                                This static function adds new handler into the list of handlers (see :ref:`wx.FileSystemHandler`) which provide access to virtual ``FS``.
:meth:`~wx.FileSystem.ChangePathTo`                                              Sets the current location.
:meth:`~wx.FileSystem.FileNameToURL`                                             Converts a :ref:`FileName`  into an URL.
:meth:`~wx.FileSystem.FindFileInPath`                                            Looks for the file with the given name `file`  in a colon or semi-colon (depending on the current platform) separated list of directories in `path`.
:meth:`~wx.FileSystem.FindFirst`                                                 Works like :meth:`~FileSystem.FindFirstFile` .
:meth:`~wx.FileSystem.FindNext`                                                  Returns the next filename that matches the parameters passed to :meth:`~FileSystem.FindFirst` .
:meth:`~wx.FileSystem.GetPath`                                                   Returns the actual path (set by :meth:`wx.FileSystem.ChangePathTo` ).
:meth:`~wx.FileSystem.HasHandlerForPath`                                         This static function returns ``True`` if there is a registered handler which can open the given location.
:meth:`~wx.FileSystem.OpenFile`                                                  Opens the file and returns a pointer to a :ref:`wx.FSFile`  object or ``None`` if failed.
:meth:`~wx.FileSystem.RemoveHandler`                                             Remove a filesystem handler from the list of handlers.
:meth:`~wx.FileSystem.URLToFileName`                                             Converts URL into a well-formed filename.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.FileSystem.Path`                                                      See :meth:`~wx.FileSystem.GetPath`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.FileSystem(Object)

   **Possible constructors**::

       FileSystem()
       
   
   This class provides an interface for opening files on different file
   systems.



   .. method:: __init__(self)

      Constructor.                  

      The initial current path of this object will be empty (i.e. :meth:`GetPath`   == EmptyString) which means that e.g. :meth:`OpenFile`   or :meth:`FindFirst`   functions will use current working directory as current path (see also GetCwd).                   





   .. staticmethod:: AddHandler(handler)

      This static function adds new handler into the list of handlers (see :ref:`wx.FileSystemHandler`) which provide access to virtual ``FS``.                  

      Note that if two handlers for the same protocol are added, the last added one takes precedence. 

                


      :param `handler`: 
      :type `handler`: wx.FileSystemHandler






      .. note:: 

         You can call: ::

                        wx.FileSystem.AddHandler(My_FS_Handler)

         This is because (a) AddHandler is a static method, and (b) the handlers are deleted in :ref:`wx.FileSystem`'s destructor so that you don't have to care about it.   








   .. method:: ChangePathTo(self, location, is_dir=False)

      Sets the current location.                  

      `location`  parameter passed to :meth:`OpenFile`   is relative to this path. 


      All these commands change the path to "dir/subdir/":  

      ::

                  ChangePathTo("dir/subdir/xh.htm")
                  ChangePathTo("dir/subdir", True)
                  ChangePathTo("dir/subdir/", True)



      Example: ::

                  f = fs.OpenFile("hello.htm") # opens file 'hello.htm'
                  fs.ChangePathTo("subdir/folder", True)
                  f = fs.OpenFile("hello.htm") # opens file 'subdir/folder/hello.htm' !!






      :param `location`: the new location. Its meaning depends on the value of is_dir   
      :type `location`: string
      :param `is_dir`: if ``True`` location is new directory. If ``False`` (the default) location is file in the new directory.   
      :type `is_dir`: bool






                  



      .. note:: 

         Unless `is_dir`  is ``True`` the `location`  parameter is not the directory name but the name of the file in this directory.  








   .. staticmethod:: FileNameToURL(filename)

      Converts a :ref:`FileName`  into an URL.                  

                


      :param `filename`: 
      :type `filename`: string




      :rtype: `string`







      .. seealso:: :meth:`URLToFileName` , :ref:`FileName`    








   .. method:: FindFileInPath(self, pStr, path, file)

      Looks for the file with the given name `file`  in a colon or semi-colon (depending on the current platform) separated list of directories in `path`.                  

      If the file is found in any directory, returns ``True`` and the full path of the file in `str`, otherwise returns ``False`` and doesn't modify `str`. 




      :param `pStr`: Receives the full path of the file, must not be ``None``   
      :type `pStr`: string
      :param `path`: PATH_SEP-separated list of directories   
      :type `path`: string
      :param `file`: the name of the file to look for   
      :type `file`: string










      :rtype: `bool`



                  





   .. method:: FindFirst(self, wildcard, flags=0)

      Works like :meth:`FindFirstFile` .                  

      Returns the name of the first filename (within filesystem's current path) that matches `wildcard`. 




      :param `wildcard`: The wildcard that the filename must match   
      :type `wildcard`: string
      :param `flags`: One of ``FILE`` (only files), ``DIR`` (only directories) or 0 (both).   
      :type `flags`: int








      :rtype: `string`



                  





   .. method:: FindNext(self)

      Returns the next filename that matches the parameters passed to :meth:`FindFirst` .                  

      :rtype: `string`








   .. method:: GetPath(self)

      Returns the actual path (set by :meth:`wx.FileSystem.ChangePathTo` ).                  

      :rtype: `string`








   .. staticmethod:: HasHandlerForPath(location)

      This static function returns ``True`` if there is a registered handler which can open the given location.                  


      :param `location`: 
      :type `location`: string




      :rtype: `bool`








   .. method:: OpenFile(self, location, flags=FS_READ)

      Opens the file and returns a pointer to a :ref:`wx.FSFile`  object or ``None`` if failed.                  

      It first tries to open the file in relative scope (based on value passed to :meth:`ChangePathTo`   method) and then as an absolute path. 

      Note that the user is responsible for deleting the returned :ref:`wx.FSFile`. `flags`  can be one or more of the :ref:`wx.FileSystemOpenFlags`  values combined together. 

      A stream opened with just the default ``wx.FS_READ``  flag may or may not be seekable depending on the underlying source. 

      Passing "wx``wx.FS_READ`` | ``wx.FS_SEEKABLE``"  for `flags`  will back a stream that is not natively seekable with memory or a file and return a stream that is always seekable. 

                


      :param `location`: 
      :type `location`: string
      :param `flags`: 
      :type `flags`: int




      :rtype: :ref:`wx.FSFile`







      .. note:: 

         The `location`  argument is, despite this method's name `not`  a filename. It is a "location", aka :ref:`wx.FileSystem`  URL (see :ref:`FileSystem Overview <filesystem overview>`).   








   .. staticmethod:: RemoveHandler(handler)

      Remove a filesystem handler from the list of handlers.                  


      :param `handler`: 
      :type `handler`: wx.FileSystemHandler




      :rtype: :ref:`wx.FileSystemHandler`








   .. staticmethod:: URLToFileName(url)

      Converts URL into a well-formed filename.                  

      The URL must use the  ``file``   protocol.                   


      :param `url`: 
      :type `url`: string




      :rtype: `string`








   .. attribute:: Path

      See :meth:`~wx.FileSystem.GetPath`