Re: low-level reading of file inside an archive?
Denis Corbin <[email protected]> Wed, 20 Jan 2010 18:54:56 +0100
| Newsgroups | gmane.comp.sysutils.backup.dar.libdar |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, Guido De Rosa a =E9crit : > Hi all, > = > is there a way to do something like this: > = > read n bytes at offset t of file path/to/my/file.ext inside a DAR > archive and put the result into a std::string or char* or something? > = > I would like to implement a read-only FUSE file system to look inside > DAR archives, and I need to perform this kind of basic I/O operations > without extracting real files to temporary directories (and then make > the I/O on the file) because this would be highly inefficient. Yep, I understand the need. In current development code (which should start its pre-release phase this year I hope), you have such a possibility: When you open an archive using the libdar API, you create an "archive" object, which provide a get_catalogue() method. The object returned by this archive::get_catalogue() method has several methods to navigate in the directory tree: catalogue::reset_read() catalogue::read() catalogue::skip_read_to_parent_dir() and also catalogue::direct_read() but which is much less efficient. the catalogue::read() method will provide you an object of class "entree" which is the root parent of several classes, among which the class "file" which corresponds to plain files, you will have to use dynamic_cast to know whether the returned object is a plain file or not and to be able to use its specific methods. The methods you will be able to use are in particular: file::get_saved_status() which will return the state of the file. If that state is "saved" then the data of that plain file is present in the archive and you can get it using the method: file::get_data() This method will return you a newly allocated generic_file object (well a pointer to that object) you will have to destroy using the delete operator. This generic_file object has the generic_file::skip() method and the generic_file::read(char *, size_t) which will provide the data you requested. > = > Thank you very much! > = Well, I cannot imagine something more simple, because accessing to one file's data assumes it is a plain file and it has been saved in the archive (in other words, its data changed since the archive of reference). In the hope this will help, Regards, Denis. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFLV0NwpC5CI8gYGlIRAuiDAJ4qEOjhLZ1sFLz7II5jOq1z8tracACeM6SU MujxmErEJgCYbxEF2ot8GjY=3D =3DQY9c -----END PGP SIGNATURE----- ---------------------------------------------------------------------------= --- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Confere= nce attendees to learn about information security's most important issues throu= gh interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev