![]() |
PDS_JP2
|
#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>
Defines | |
#define | _VERSION_ " " |
#define | BACKUP_FILENAME_SUFFIX "-backup" |
Suffix appended to input pathname to create backup pathname. | |
Functions | |
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. | |
Variables | |
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 | EXISTING_BACKUP_FILE = 22 |
const int | IO_FAILURE = 29 |
const int | JP2_ERROR = 30 |
const char * | ID = "(1.3 2019/03/26 20:50:57)" |
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 _VERSION_ " " |
#define BACKUP_FILENAME_SUFFIX "-backup" |
Suffix appended to input pathname to create backup pathname.
Referenced by main().
void usage | ( | const char * | program_name, |
int | exit_status = BAD_SYNTAX , |
||
bool | list_descriptions = false |
||
) |
Application command line syntax and usage.
relocate_label [Options] [-Input] <pathname> -Location <pathname>
The pathname of the input JP2 file.
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_name | The name of the executable. This is expected to be the first entry in the main arguments list. |
exit_status | This method always result in program exit. If the exit status value is not specified the BAD_SYNTAX value will be used. |
list_descriptions | If true, long option descriptions will be listed; otherwise only the brief option syntax is listed. |
kdu_uint32 box_type | ( | const char * | box_name ) |
Referenced by JP2_Box::append_content(), main(), JP2_Decoder::open(), and JP2_Box::type_code().
string box_name | ( | kdu_uint32 | box_type ) |
Referenced by JP2_Box::add(), JP2_Box::JP2_Box(), main(), and JP2_Decoder::open().
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.
argument_count | The number of command line arguments. |
arguments | The array of command line arguments. |
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.
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().
const int EXISTING_BACKUP_FILE = 22 |
Referenced by main().
const int IO_FAILURE = 29 |
const char* ID = "(1.3 2019/03/26 20:50:57)" |
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().