fs_wxz.cpp

00001 
00002 // Name:        fs_wxz.cpp
00003 // Purpose:     wxWxzFSHandler
00004 // Author:      Francesco Montorsi
00005 // Modified by:
00006 // Created:     2007-1-17
00007 // RCS-ID:      $Id: fs_wxz.cpp,v 1.1 2007/01/18 00:01:29 frm Exp $
00008 // Copyright:   (c) Francesco Montorsi
00009 // Licence:     wxWidgets licence
00011 
00012 
00013 // For compilers that support precompilation, includes "wx/wx.h".
00014 #include "wx/wxprec.h"
00015 
00016 #ifdef __BORLANDC__
00017 #pragma hdrstop
00018 #endif
00019 
00020 #ifndef WX_PRECOMP
00021     #include "wx/wx.h"
00022 #endif
00023 
00024 // includes
00025 #include <wx/filesys.h>
00026 #include "wxp/fs_wxz.h"
00027 
00028 
00029 // ----------------------------------------------------------------------------
00030 // wxWxzFSHandler
00031 // ----------------------------------------------------------------------------
00032 
00033 IMPLEMENT_DYNAMIC_CLASS(wxWxzFSHandler, wxFileSystemHandler)
00034 
00035 bool wxWxzFSHandler::CanOpen(const wxString& location)
00036 {
00037     wxString p = GetProtocol(location);
00038     return p == wxT("wxz");
00039 }
00040 
00041 wxFSFile* wxWxzFSHandler::OpenFile(wxFileSystem& fs, const wxString& location)
00042 {
00043     wxString right = GetRightLocation(location);
00044     wxString left = GetLeftLocation(location);
00045     /*
00046     wxString protocol = GetProtocol(location);
00047     wxString key = left + wxT("#") + protocol + wxT(":");*/
00048 
00049     // just look at the left location to understand which type of
00050     // archive is this "WXZ"
00051     wxString ext = wxFileName(left).GetExt();
00052 
00053     // exception: if the file is "name.tar.gz" we want to consider as
00054     // extension the entire ".tar.gz"
00055     wxString newloc;
00056     if (left.EndsWith(wxT(".tar.gz")))
00057     {
00058         // for .tar.gz archives we need to create
00059         // the location in the form:
00060         //     srchive.tar.gz#gzip:#tar:filename
00061         newloc = left + wxT("#gzip:#tar:") + right;
00062     }
00063     else
00064     {
00065         // for ZIPs it's easier:
00066         newloc = left + wxT("#") + ext + wxT(":") + right;
00067     }
00068 
00069     // open this file using the other file system handlers
00070     wxFileSystem temp;
00071     return temp.OpenFile(newloc);
00072 }
00073 
00074 wxString wxWxzFSHandler::FindFirst(const wxString& spec, int flags)
00075 {
00076     return wxEmptyString;
00077 }
00078 
00079 wxString wxWxzFSHandler::FindNext()
00080 {
00081     return wxEmptyString;
00082 }
00083 
00084 

Generated on Thu Feb 1 22:14:31 2007 for wxWidgets Package Manager by  doxygen 1.5.1-p1