Add wxFS_SEEKABLE open flag.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42488 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -166,6 +166,13 @@ protected:
|
|||||||
// kinds of files (HTPP, FTP, local, tar.gz etc..)
|
// kinds of files (HTPP, FTP, local, tar.gz etc..)
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Open Bit Flags
|
||||||
|
enum {
|
||||||
|
wxFS_READ = 1, // Open for reading
|
||||||
|
wxFS_WRITE = 2, // Open for writing
|
||||||
|
wxFS_SEEKABLE = 4 // Returned stream will be seekable
|
||||||
|
};
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxFileSystem : public wxObject
|
class WXDLLIMPEXP_BASE wxFileSystem : public wxObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -187,7 +194,7 @@ public:
|
|||||||
// It first tries to open the file in relative scope
|
// It first tries to open the file in relative scope
|
||||||
// (based on ChangePathTo()'s value) and then as an absolute
|
// (based on ChangePathTo()'s value) and then as an absolute
|
||||||
// path.
|
// path.
|
||||||
wxFSFile* OpenFile(const wxString& location);
|
wxFSFile* OpenFile(const wxString& location, int flags = wxFS_READ);
|
||||||
|
|
||||||
// Finds first/next file that matches spec wildcard. flags can be wxDIR for restricting
|
// Finds first/next file that matches spec wildcard. flags can be wxDIR for restricting
|
||||||
// the query to directories or wxFILE for files only or 0 for either.
|
// the query to directories or wxFILE for files only or 0 for either.
|
||||||
@@ -205,7 +212,6 @@ public:
|
|||||||
// Removes FS handler
|
// Removes FS handler
|
||||||
static wxFileSystemHandler* RemoveHandler(wxFileSystemHandler *handler);
|
static wxFileSystemHandler* RemoveHandler(wxFileSystemHandler *handler);
|
||||||
|
|
||||||
|
|
||||||
// Returns true if there is a handler which can open the given location.
|
// Returns true if there is a handler which can open the given location.
|
||||||
static bool HasHandlerForPath(const wxString& location);
|
static bool HasHandlerForPath(const wxString& location);
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "wx/mimetype.h"
|
#include "wx/mimetype.h"
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
|
#include "wx/fileback.h"
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
@@ -357,7 +358,7 @@ void wxFileSystem::ChangePathTo(const wxString& location, bool is_dir)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
wxFSFile* wxFileSystem::OpenFile(const wxString& location)
|
wxFSFile* wxFileSystem::OpenFile(const wxString& location, int flags)
|
||||||
{
|
{
|
||||||
wxString loc = MakeCorrectPath(location);
|
wxString loc = MakeCorrectPath(location);
|
||||||
unsigned i, ln;
|
unsigned i, ln;
|
||||||
@@ -410,6 +411,15 @@ wxFSFile* wxFileSystem::OpenFile(const wxString& location)
|
|||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s && (flags & wxFS_SEEKABLE) != 0 && !s->GetStream()->IsSeekable())
|
||||||
|
{
|
||||||
|
wxBackedInputStream *stream;
|
||||||
|
stream = new wxBackedInputStream(s->DetachStream());
|
||||||
|
stream->FindLength();
|
||||||
|
s->SetStream(stream);
|
||||||
|
}
|
||||||
|
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user