Font size:      

j4copy Concepts

Basics

j4copy executes elementary tasks consisting in copying files. Each j4copy elementary task is called an "item" of work. Items can be "grouped" to ease operations on several items at once (operations on a group are applied to each of its elements, one after the other). All these items are stored in an XML file, defining a set of items. Thus, this XML file tells j4copy what it has to do.

An element is either a group of elements or an item. This way, a j4copy XML file is an element tree with a root, some nodes which are groups, and some leaves which are items (this is very similar to a file tree with directories and files). Elements are referenced through a relative or absolute name, which is composed of intermediate names separated by '/' (slash).

For instance: group1/group11/item111

Elements

Elements (i.e. groups and items) feature several common properties:

  • name - this is the name of the element (character '/' is prohibited)
  • active flag - this boolean tells if the element is active or not; inactive elements are ignored for checking and execution

Items

Items have several specific properties:

  • source directory - this path defines source directory for the item
  • recursive flag - this flag defines whether to proceed source subdirectories or not
  • include filespecs - this string specifies files to include (supports wildcards)
  • exclude filespecs - this string specifies files to exclude (supports wildcards)
  • ignore case - this boolean tells if case in source filenames/dirnames should be ignored
  • destination directory - this path defines where files are to be copied to
  • type - the item type
    • TYPE_COPY - copy source files to destination
    • TYPE_ARCHIVE - copy source files into a new archive/zip file in destination
    • TYPE_SYNCHRO - synchronize source files and destination files (i.e. bidirectional copy)
  • clean before copy - this boolean tells if destination directory should be cleaned before copy
  • preserve tree - this flag defines if file tree structure is preserved or "flatened"
  • incremental - this boolean indicates that only files modified since last run should be copied
  • differential - this flag means: only files that are more recent in source directory than in destination directory should be copied
  • archive filename encoding - this string defines the encoding to use for archive filenames and paths
  • cycling level - this integer (from 0 to 999) represents the cycling number of backup'ed versions (0 means no backup)
  • control subdirectory - this destination subdirectory is used for control file and cycling subdirectories

Note on incremental/differential: incremental flag can lead to tricky situations where some files are ommitted during copy (e.g.: if some files older than last execution are copied into source directory). It should be used with care, when one wants that destination only contains a subset of source files (e.g.: all files modified since the start of your project). In other cases, differential mode is preferrable, since it evalutes the actual difference between source and destination files to decide which ones to copy. It is also possible to combine these two flags (e.g.: synchronisation with incremental mode).

Control file and cycling

j4copy uses a control file (in a specific destination subdirectory) to store the timestamp of last execution. This file is read at the beginning of each new execution and overwritten at the end.

In addition, control subdirectory contains backup subdirectories to store old versions of files, whenever a newer version is copied to destination. For instance, if version N of a file is copied during execution of an item, version N-1 of the file in destination directory will be put in xxx.000, version N-2 in xxx.001, and so on. These subdirectories are cycled so that the number of retained old versions keeps constant.