viksoe.dk

TAR Folder shell extension

TAR Folder shell extension


This article was submitted .


This is a Shell Namespace Extension that expands .tar archive files in Windows Explorer. It allows you to browse into a tar file and view the embedded files in Windows Explorer, just like you can browse into a compressed zip file.

This virtual folder works in Windows Vista or better.

TAR archives are often used on UNIX-based systems, and is short for Tape ARchive. TAR files are usually used for file backup purposes and are uncompressed, so they are used in conjunction with compression software, such as GZIP or BZIP.

This Shell Extension expands the .tar file-extension and allows you to browse into the archive as if it was an actual disk folder. You can copy and paste files and folders in and out of the archive inside Windows Explorer.
You can double-click to open a file and edit it. Save the file back and, if needed, even use the Windows Vista SaveFile dialog to save it with a new name.
When you browse the tar file, you'll get an Extract button in the command bar in the Windows Vista Explorer menu area. Use it to extract an entire folder, or you can simply drag'n'drop files out of the folder.
In addition, the shell extension offers new Property Sheet pages for both the TAR archive itself and also all its files and folders. Use the right-click menu on any folder or sub-folder to quickly extract all files in that folder.

This virtual folder does not support compressed tar files. Files with the extension .tgz and .tbz do not expand.

The Source Code

This is the 2nd sample that demonstrates a set of generic Shell Namespace Extension C++ classes I wrote. The first sample, the Registry Extension, exposed a common virtual folder in the My Computer folder. This TAR Folder sample, however, implements a rooted, multi-level namespace extension that extends a file-extension.

Most of the functionality is handled by my generic C++ classes, so to create the virtual file-system namespace extension, only a thin wrapper around the CNseFileItem class is needed. For clarity, the actual file-system (in this case the TAR archive format) is presented as an external API. It provides the basic primitives that any file-system would offer, such as...

  •  tar_readfile
  •  tar_writefile
  •  tar_deletefile
  •  tar_renamefile
  •  tar_getfilelist
There are two issues that are very important:
Multi-threading  The C++ classes and Windows Explorer are highly multi-threaded so it is important to protect your internal file-system structures from multiple threads writing to shared memory.
CachingYou'll need to consider how to cache the directory structures for fast retrieval.

For this TAR folder sample, reading the entire directory structure is a fairly speedy process so the sample uses a caching mechanism already available in my C++ framework by putting the list in the CNseFileSystem derived class. This class is carried around along with the IShellFolder instance and its offspring as the Windows Explorer already tries to reuse a single instance for optimized throughput. But when implementing a virtual file-system on a slower media, you'll need to cleverly cache lists to give the expected user experience in Windows Explorer.

This sample runs on Windows Vista or better. It uses APIs specific to the versions of Windows after Windows XP since they offer several improvements for developing shell extensions. If you wish to explore the possibilities for supporting older instances of Windows, check out my ADF View sample.

Source Code Dependencies

Windows Vista
Microsoft Visual Studio.NET 2008
Microsoft ATL Library

See Also

A Shell Extension in the My Computer folder
A Shell Extension to browse Flickr photos

Download Files  This software is free!

DownloadInstallation file (271 Kb)
Source Code (349 Kb)

To the top