artefaktur
software engineer &        architecture

 
 
 
 

acdk_vfile Manual


acdk_vfile provides acdk::io::File plugins for reading tar and zip files.


Content of this chapter:

   Introduction
   Usage
     Reading archive files
     Writing archive files
   Embedding archive files into ressources
   Tar files
   ZIP files



 Introduction

acdk_vfile contains plugin for ACDK virtual file system framework. With acdk_vfile such virtual file system for tar and zip files are provided.

 Usage

 Reading archive files


To address the root directory of an archive, you have to add the character '@' at the end of the filename.

On a given Filename:
/home/roger/myarchive.tar
or
d:\home\roger\myarchive.zip
the filename
/home/roger/myarchive.tar@
or
d:\home\roger\myarchive.zip@
represents the root directory of archive.


#include <acdk/io/MemWriter.h>
#include <acdk/io/File.h>
#include <acdk/vfile/tar/TarFileSystem.h>
#include <acdk/vfile/zip/ZipFileSystem.h>

RbytArray readFile()
{
  // just to make sure that library will be loaded
  acdk::vfile::zip::ZipFileSystem::loadFileSystem();
  
  RString fname = "/home/roger/myarchive.tar@mydir/myfile.c"
  File archivefile(fname);
  acdk::io::RReader reader = archivefile.getReader();
  acdk::io::MemWriter memwriter;
  reader->trans(&memwriter);
  return memwriter.getBuffer()
}

 Writing archive files

Writing archive files is not yet supported.

 Embedding archive files into ressources

You can integrate a collection of files as archive file into your application using the virtual file system '.ressource@'.

  • create an archive containing the files with an external tool (tar, infozip, WinZip, etc.).

  • use acdk_vfile_file2rc to convert the archive file into an c file. acdk_vfile_file2rc myarchive.zip myarchiv.c
  • create the node in the ressource file system.
    
    
    #include <acdk/io/RessourceFileSystem.h>
    #include <acdk/vfile/zip/ZipFileSystem.h>
    
    // include the ressource file
    #include "myarchive.c"
    
    // call this before using ressource
    void initMyRessource()
    {
      static bool inited = false;
      if (inited  == true) // don't intilize twice
        return;
      
      acdk::io::RessourceFileSystem::ressourceFileSystem() // get the RessourceFileSystem
          ->root()                               // Root directory of RessourceFileSystem
             ->createFile("com/myfirm/my/project/myarchive.zip", 
                          ressource_array, // use byte array as content of file
                          ressource_size, 
                          );
                             
      // make sure, that zip file system plugin is loaded
      acdk::vfile::zip::ZipFileSystem::loadFileSystem();
    }
    

  • In our code, after initMyRessource called you can the files inside archive:
    
    void foo()
    {
      initMyRessource();
      RString myfile = ".ressource@com/myfirm/my/project/myarchive.zip@/mysub/myfile.txt";
      acdk::io::File zf(myfile);
      acdk::io::RReader in = zf.getReader();
      // read content from the file.
    }
    


 Tar files

Tar files can be readed. Not very good test yet.
File time, attributes, etc. are not yet implemented.

 ZIP files

ZIP files can be readed, although some files contains unsupported compression algorithms.
ACDK uses for compression/decompression the zlib library, which can be found in the acdk_vfile/src/acdk/vfile/zlib directory.

My implementation only reads the local file headers (not the central directory located at the end of the zip file). This may also cause problems with some ZIP files.

File time, attributes, etc. are not yet implemented.
 
Last modified 2005-05-08 22:30 by SYSTEM By Artefaktur, Ing. Bureau Kommer