logical puzzle: how to generate reasonable archive file names fromfile and directory names

F

fBechmann

I'm writing a module to convert between filesystem nodes
(directory,file) and various archives (gz, zip, tgz).

For this I want to automatically create reasonable file names for the
archives where these file names depend from the type of the file system
node to be archived and from the type of the archive to be created.

I want the following transformations to take place:

Dir
abc =(gz)=> *not allowed*
=(zip,tgz)=> abz.zip,abc.tgz
abc.XY =(gz)=> *not allowed*
=(zip,tgz)=> abc.XY.zip,abc.XY.tgz

File
abc =(gz)=> abc.gz
=(zip,tgz)=> abz.zip,abc.tgz
abc.ext =(gz)=> abc.ext.gz
=(zip,tgz)=> abc.zip,abc.tgz

For the decision to remove the extension from the file or directory this
gives me the following table:

gz zip,tgz
Dir *n.a.* no
File no yes

I have the classes Dir, File, ArchiveGZ and MultiFileArchive (base class
for ArchiveTGZ and ArchiveZIP, which share behaviour w/ respect to that
naming transformation).

I've found a way which looks quite cruel (and which I'll post later), so
I have the hope that someone here finds a nice snippet of code for this.

thx in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,654
Latest member
LannySinge

Latest Threads

Top