Selective Directory Copying: SDC

Summary: This package facilitates the copying of a selected subset of a source directory (and its subdirectories) to a target directory. The selection of files and directories is based on designated -.sdc files in each of the involved source directories.

How to get and install the tool: If you want want to use this tool you must download the file multi-sdc.el

How to use the tool: There is a single, important function in this tool:

  (sdc-copy-directory selector from-directory-path directory into-directory-path)

The function copies the directory (concat from-directory-path "/" directory) to a subdirectory named directory of into-directory-path. Both from-directory-path and into-directory-path are full paths. In the copy process a few special files guide the copying: only.sdc, not.sdc, remote.sdc and rename.sdc. The only.sdc file enumerates the file and directories to be copied. The contents of these files can be a list of strings. The not.sdc file enumerates the files and directories to be ignored during the copy process. It is not allowed to have both a not.sdc and a only.sdc file in the same directory. The not and only files are never copied themselves. If a rename.sdc file (containing a single string) exists in a directory, that directory will be renamed in the copy process to the string in the rename.sdc file. The file remote.sdc makes it possible to include files from other destinations in the copy process. The selector parameter selects one of several parts of an SDC file (see the example below). Use the selector 'all if selections are not used.

Not and only SDC files have, in general, the following structure:

  (
    selector-1 ("file-1" ... "file-n")
    ...
    selector-k ("file-1" ... "file-m")
  )

remote.sdc files have the following structure:

  (
    ("file-path-1" "f1")    
    ...
    ("file-path-n" "fn")
  )

and the meaning that file-path-1 is fused into the current directory as f1, etc.

rename.sdc files just contain a single text string, asking for a simple renaming of the current directory in the copy process.

rename and remote files do not support selectors yet.

 

Sample source directory structure: Here is a sample source directory structure (d1 and d2) with a number of files and sdc files. The only files define two selections: sel1 and sel2. The call:

     (sdc-copy-directory 'sel1
       "/user/normark/.public_html/emacs-lisp/selective-directory-copying"
       "sample-sdc-dir"
       "/user/normark/temp/"
     ) 

derives this target directory. That is, f1.txt and the directory d2 is copied. The remote file (which happens to be the el source) is copied into source.el. The only.sdc file in d2 is common for both sel1 and sel2. It asks for copying of f5.txt.

Similarly, the call:

     (sdc-copy-directory 'sel2
       "/user/normark/.public_html/emacs-lisp/selective-directory-copying"
       "sample-sdc-dir"
       "/user/normark/temp/") 

derives this target directory. That is, f2.txt is copied; The directory d1 is copied, and renamed to xxx. As for sel1, the remote file (which happens to be the el source) is copied into source.el. In the renamed d1 directory, f7.txt is not copied (but ooo and f6.txt) are copied.

 

Practical use of SDC: During the last few years, I used the SDC facility to support the derivation of three different LAML distributions from my development version of LAML.

 

Disclaimer: Aalborg University and Kurt Nørmark shall NOT be responsible for any harm caused by the use of this tool.

 
Kurt Nørmark
normark@cs.aau.dk
http://www.cs.aau.dk/~normark/