HiRISE
 PDS_JP2

Macros | 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:

Macros

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

Functions

void usage (const char *program_name, int exit_status=BAD_SYNTAX, bool list_descriptions=false)
 Application command line syntax and usage. More...
 
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. More...
 

Variables

const int SUCCESS = 0
 Exit status values. More...
 
const int BAD_SYNTAX = 1
 
const int NO_INPUT_FILE = 20
 
const int NO_LABEL_LOCATION = 21
 
const int EXISTING_BACKUP_FILE = 22
 
const int IO_FAILURE = 29
 
const int JP2_ERROR = 30
 
const char * ID
 Application identification name with source code version and date. More...
 
char * Program_Name
 The runtime command name. More...
 
const char *const UUID_INFO_BOX_NAME = "uinf"
 JP2 UUID Info and URL box names. More...
 
const char *const *const URL_BOX_NAME = "url "
 
const int VERS_AND_FLAG_BYTES = 4
 

Macro Definition Documentation

◆ _VERSION_

#define _VERSION_   " "

◆ BACKUP_FILENAME_SUFFIX

#define BACKUP_FILENAME_SUFFIX   "-backup"

Suffix appended to input pathname to create backup pathname.

Function Documentation

◆ usage()

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.

-No_]Backup

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.

-Help

Prints this usage description.

Parameters
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**)

Referenced by main().

◆ box_type()

kdu_uint32 box_type ( const char *  box_name)

◆ box_name()

string box_name ( kdu_uint32  box_type)

◆ main()

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:

SUCCESS
The application completed successfully.
BAD_SYNTAX
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_FILE
No input JP2 file pathname was specified or the pathname does not exist.
NO_LABEL_LOCATION
No PDS label file location was specified on the command line.
EXISTING_BACKUP_FILE
A file with the name of the input JP2 and a "-backup" suffix exists, but the -Force option was not specified to force overwriting.
IO_FAILURE
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.
JP2_ERROR
The input file is not a valid JP2 file or does not contain the required URL box with a pathname value.
Parameters
argument_countThe number of command line arguments.
argumentsThe array of command line arguments.
See also
usage(const char*, int, bool)
Author
Bradford Castalia, UA/HiROC
Version
1.3

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

Variable Documentation

◆ SUCCESS

const int SUCCESS = 0

Exit status values.

Referenced by main().

◆ BAD_SYNTAX

const int BAD_SYNTAX = 1

Referenced by main().

◆ NO_INPUT_FILE

const int NO_INPUT_FILE = 20

Referenced by main().

◆ NO_LABEL_LOCATION

const int NO_LABEL_LOCATION = 21

Referenced by main().

◆ EXISTING_BACKUP_FILE

const int EXISTING_BACKUP_FILE = 22

Referenced by main().

◆ IO_FAILURE

const int IO_FAILURE = 29

Referenced by main().

◆ JP2_ERROR

const int JP2_ERROR = 30

Referenced by main().

◆ ID

const char* ID
Initial value:
=
"relocate_label"
"(1.3 2019/03/26 20:50:57)"
#define _VERSION_
Definition: relocate_label.cc:62

Application identification name with source code version and date.

Referenced by main().

◆ Program_Name

char* Program_Name

The runtime command name.

◆ UUID_INFO_BOX_NAME

const char* const UUID_INFO_BOX_NAME = "uinf"

JP2 UUID Info and URL box names.

Referenced by main().

◆ URL_BOX_NAME

const char* const * const URL_BOX_NAME = "url "

Referenced by main().

◆ VERS_AND_FLAG_BYTES

const int VERS_AND_FLAG_BYTES = 4

Referenced by main().