Defines | Functions | Variables

relocate_label.cc File Reference

#include "jp2.h"
#include "Files.hh"
#include "endian.hh"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include <stdexcept>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cerrno>
Include dependency graph for relocate_label.cc:


#define _VERSION_   " "
#define BACKUP_FILENAME_SUFFIX   "-backup"
 Suffix appended to input pathname to create backup pathname.


void usage (const char *program_name, int exit_status=BAD_SYNTAX, bool list_descriptions=false)
 Application command line syntax and usage.
kdu_uint32 box_type (const char *box_name)
string box_name (kdu_uint32 box_type)
int main (int argument_count, char **arguments)
 relocate_label application.


const int SUCCESS = 0
 Exit status values.
const int BAD_SYNTAX = 1
const int NO_INPUT_FILE = 20
const int NO_LABEL_LOCATION = 21
const int IO_FAILURE = 29
const int JP2_ERROR = 30
const char * ID = "(1.2 2012/02/04 01:29:26)"
 Application identification name with source code version and date.
char * Program_Name
 The runtime command name.
const char *const UUID_INFO_BOX_NAME = "uinf"
 JP2 UUID Info and URL box names.
const char *const *const URL_BOX_NAME = "url "
const int VERS_AND_FLAG_BYTES = 4

Define Documentation

#define _VERSION_   " "
#define BACKUP_FILENAME_SUFFIX   "-backup"

Suffix appended to input pathname to create backup pathname.

Referenced by main().

Function Documentation

void usage ( const char *  program_name,
int  exit_status = BAD_SYNTAX,
bool  list_descriptions = false 

Application command line syntax and usage.

Command line syntax:

relocate_label [Options] [-Input] <pathname> -Location <pathname>

Command line options:

[-Input] <pathname>

The pathname of the input JP2 file.

-Location <pathname>

The pathname of the label file. The pathname must be relative to the location of the JP2 file.


When the JP2 file is modified it is first renamed by appending a "-backup" suffix the the filename before being copied to a file with the original name and modified contents. If the -Backup option is specified the original file, now with the "-backup" suffix in its filename, will remain; otherwise the backup file is deleted when the operation completes.

Default: Do not leave a backup file.


Prints this usage description.

program_nameThe name of the executable. This is expected to be the first entry in the main arguments list.
exit_statusThis method always result in program exit. If the exit status value is not specified the BAD_SYNTAX value will be used.
list_descriptionsIf true, long option descriptions will be listed; otherwise only the brief option syntax is listed.
See also:
main(int, char**)
kdu_uint32 box_type ( const char *  box_name )
string box_name ( kdu_uint32  box_type )
int main ( int  argument_count,
char **  arguments 

relocate_label application.

The pathname reference to the location of the external label file associated with a PDS/JP2 data set is changed in a JP2 file.

The specification of a PDS/JP2 data set requires that the JP2 file contains a URL box, a sub-box of a UUID Info box, with a value that provides the pathname of the external PDS metadata label file for the data set. The URL value is a simple filesystem pathname (no protocol/scheme prefix) that must be relative the location of the JP2 file.

N.B.: The external label file is not modified or moved. If the file does not exist at the new location a warning is provided.

The input file is checked for being a valid JP2 file with a UUID Info box containing the required URL box. If the existing pathname that is found is the same as the specified new pathname nothing is done. Otherwise the JP2 file is moved to a backup file having the same name with a "-backup" suffix and this is copied to a new file having the original name with the modified UUID Info box replacing the previous box; no other changes are made to the JP2 file. The backup file is removed after the new JP2 file is successfully written unless the -No_Backup option is specified.

Exit status values:

The application completed successfully.
There was a syntax problem in the command line, or the label file location is an absolute pathname rather than being relative to the JP2 file location.
No input JP2 file pathname was specified or the pathname does not exist.
No PDS label file location was specified on the command line.
A file with the name of the input JP2 and a "-backup" suffix exists, but the -Force option was not specified to force overwriting.
A filesystem I/O failure has occurred. This will occur it the input file or its backup can not be read, or the new output file can not be written.
The input file is not a valid JP2 file or does not contain the required URL box with a pathname value.
argument_countThe number of command line arguments.
argumentsThe array of command line arguments.
See also:
usage(const char*, int, bool)
Bradford Castalia, UA/HiROC

References BACKUP_FILENAME_SUFFIX, BAD_SYNTAX, box_name(), box_type(), EXISTING_BACKUP_FILE, PIRL::file_directory_pathname(), PIRL::file_exists(), PIRL::file_is_normal(), PIRL::file_is_readable(), PIRL::file_is_writeable(), PIRL::FILE_PATHNAME_DELIMITER, ID, IO_FAILURE, JP2_ERROR, PIRL::MSB_native(), NO_INPUT_FILE, NO_LABEL_LOCATION, SUCCESS, URL_BOX_NAME, usage(), UUID_INFO_BOX_NAME, and VERS_AND_FLAG_BYTES.

Variable Documentation

const int SUCCESS = 0

Exit status values.

const int BAD_SYNTAX = 1
const int NO_INPUT_FILE = 20
const int NO_LABEL_LOCATION = 21

Referenced by main().


Referenced by main().

const int IO_FAILURE = 29
const int JP2_ERROR = 30

Referenced by main().

const char* ID = "(1.2 2012/02/04 01:29:26)"

Application identification name with source code version and date.

char* Program_Name

The runtime command name.

const char* const UUID_INFO_BOX_NAME = "uinf"

JP2 UUID Info and URL box names.

Referenced by main().

const char* const * const URL_BOX_NAME = "url "

Referenced by main().

const int VERS_AND_FLAG_BYTES = 4

Referenced by main().