47 Log::error(
Say(
"ZippedDirectory() could not locate zip file '%s'.\n") << zip_file );
63 Log::error(
"ZippedDirectory::setPath() given an empty path.\n");
72 std::map< String, ref<ZippedFile> > file_map;
78 Log::warning(
Say(
"ZippedDirectory::setPath() : invalid path file '%s'.\n") << p );
82 it->second->setPath(root + p);
83 file_map[it->second->path()] = it->second;
119 Log::error(
"VirtualDirectory::path() must not be empty!\n" );
125 Log::error(
"ZippedFile::init() called but not zip file mounted.\n");
131 Log::error(
"ZippedDirectory::init(): cannot open source zip file.\n");
135 for(
unsigned int local_file_header_signature = 0;
136 zip->
read(&local_file_header_signature, 4) && local_file_header_signature == 0x04034b50;
137 local_file_header_signature = 0 )
143 unsigned short last_mod_file_time;
144 unsigned short last_mod_file_date;
160 std::string file_name;
162 zip->
read(&file_name[0], file_name.size());
163 file_name.push_back(0);
181 std::vector<char> extra_field;
183 zip->
read(&extra_field[0], extra_field.size());
190 zfile_info->
mSecond = int(( last_mod_file_time & 31 ) / 31.0f * 59.5f);
191 zfile_info->
mMinute = (last_mod_file_time>>5) & 63;
192 zfile_info->
mHour = (last_mod_file_time>>11) & 31;
193 zfile_info->
mDay = last_mod_file_date & 31;
194 zfile_info->
mMonth = (last_mod_file_date>>5) & 15;
195 zfile_info->
mYear = ((last_mod_file_date>>9) & 127 ) + 1980;
199 printf(
"-------------------------\n");
207 printf(
"mCRC32 = %08X\n", zfile_info->
mCRC32);
211 long long cur_pos = zip->
position();
214 if (cur_pos < 2*4 + 4*4)
216 Log::error(
"ZippedDirectory::init(): mounted a non seek-able zip file.\n");
231 if (zfile_info->
mCRC32 == 0x08074b50)
255 return (
int)
mFiles.size();
260 std::map< String, ref<ZippedFile> >::const_iterator it =
mFiles.begin();
261 for(
int i=0; i<index && it !=
mFiles.end(); ++i)
266 return it->second.get();
271 std::map< String, ref<ZippedFile> >::iterator it =
mFiles.begin();
272 for(
int i=0; i<index && it !=
mFiles.end(); ++i)
277 return it->second.get();
283 std::map< String, ref<ZippedFile> >::const_iterator it =
mFiles.find(p);
289 zip_file->operator=(*it->second);
290 return zip_file.
get();
299 Log::error(
"VirtualDirectory::path() must not be empty!\n" );
304 if (!it->first.startsWith(
path()))
306 file_list.push_back( it->first );
316 Log::error(
"VirtualDirectory::path() must not be empty!\n" );
319 std::set<String> sub_dirs;
326 while(p.startsWith(
'/'))
329 if (p.length()>3 && p[1] ==
':' && p[2] ==
'/')
331 drive_letter = p.
left(3);
336 std::vector<String> tokens;
337 p.
split(
'/',tokens,
true);
339 sub_dirs.insert(
path() + tokens[0]);
341 for(std::set<String>::const_iterator it = sub_dirs.begin(); it != sub_dirs.end(); ++it)
349 Log::error(
"VirtualDirectory::path() must not be empty!\n" );
356 if (it->first.startsWith(p+
'/'))
376 Log::error(
"VirtualDirectory::path() must not be empty!\n" );
381 if (it->first.extractPath().left(-1) ==
path())
382 file_list.push_back( it->first );
long long read(void *buffer, long long byte_count)
Reads byte_count bytes from a file. Returns the number of bytes actually read.
VLCORE_EXPORT FileSystem * defFileSystem()
Returns the default FileSystem used by VisualizationLibrary.
const VirtualFile * sourceZipFile() const
std::map< String, ref< ZippedFile > > mFiles
An abstract class representing a file.
Collects the information about a ZippedFile.
A simple String formatting class.
static void warning(const String &message)
Use this function to provide information about situations that might lead to errors or loss of data...
String & resize(int character_count)
Resizes the string to the specified character count.
static String fromUTF8(const char *str, int byte_count=-1)
Accepts strings with and without UTF8 signature.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
unsigned short mCompressionMethod
bool seekCur(long long offset)
Changes the current read/write position of a file.
unsigned short mExtraFieldLength
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
String extractPath() const
If the String contains a file path the function returns the path with trailing slash, without the file name.
ref< VirtualFile > mSourceZipFile
virtual ref< VirtualFile > locateFile(const String &full_path, const String &alternate_path=String()) const
Looks for a VirtualFile on the disk and in the currently active FileSystem.
bool setPath(const String &name)
Changes the path name of a VirtualDirectory. Must not be an empty string.
ref< ZippedDirectory > zippedSubDir(const String &subdir_name) const
String left(int count) const
Returns the count leftmost caracters of a String. If count is negative the function returns all but t...
String & normalizeSlashes()
Transform \ slashes in / slashes and removes duplicates.
String & trim(wchar_t ch)
Removes the specified character ch from the beginning and the end of the String.
virtual void close()=0
Closes the file.
ref< VirtualFile > file(const String &name) const
Returns the VirtualFile with the given name if any, NULL otherwise.
const String & path() const
Returns the path of the file.
Visualization Library main namespace.
virtual const String & path() const
void setZippedFileInfo(ZippedFileInfo *info)
unsigned short mFileNameLength
void setSourceZipFile(VirtualFile *file)
bool empty() const
Returns true if length() == 0.
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
void split(wchar_t separator, std::vector< String > &fields, bool remove_empty_fields=false) const
Splits a String into a set of fields. The fields are separated by the specified separator and are ret...
bool startsWith(const String &str) const
Returns true if a String starts with the specified String str.
void listSubDirs(std::vector< String > &dirs, bool append=false) const
void setSourceZipFile(VirtualFile *file)
unsigned short mGeneralPurposeFlag
unsigned int mZippedFileOffset
unsigned short readUInt16(bool little_endian_data=true)
Reads single entry.
void setPath(const String &name)
Changes the path bound to a VirtualFile. Use carefully this function, you shouldn't rename a VirtualF...
int zippedFileCount() const
void reset()
Sets the source zip file to NULL and disposes all the files contained in this directory.
void listFilesRecursive(std::vector< String > &file_list) const
Returns the list of files contained in the VirtualDirectory.
ref< ZippedFile > zippedFile(const String &name) const
Accepts absolute and relative paths.
unsigned int readUInt32(bool little_endian_data=true)
Reads single entry.
The ref<> class is used to reference-count an Object.
unsigned short mVersionNeeded
String right(int count) const
Returns the count rightmost caracters of a String. If count is negative the function returns all but ...
std::string toStdString() const
Returns a UTF8 encoded std::string.
bool endsWith(const String &str) const
Returns true if a String ends with the specified String str.
long long position() const
Returns the current position in the file.
String translatePath(const String &p) const
void listFiles(std::vector< String > &file_list, bool append=false) const
A VirtualFile used to read a file contained in a .zip archive.
unsigned int mCompressedSize
unsigned int mUncompressedSize