cbmimage
Loading...
Searching...
No Matches
Directory processing functions

Classes

struct  cbmimage_dir_header_name_s
 The name of a directory header or directory entry. More...
 
struct  cbmimage_dir_header_s
 A directory header. More...
 
struct  cbmimage_dir_entry_s
 A directory entry. More...
 
struct  cbmimage_i_dir_entry_internal_s
 internal data for directory entry More...
 

Typedefs

typedef enum cbmimage_dir_type_e cbmimage_dir_type
 The type of a directory entry cbmimage_dir_entry_s.
 
typedef enum cbmimage_geos_filetype_e cbmimage_geos_filetype
 The GEOS type of a directory entry cbmimage_dir_entry_s.
 
typedef struct cbmimage_dir_header_name_s cbmimage_dir_header_name
 The name of a directory header or directory entry.
 
typedef struct cbmimage_dir_header_s cbmimage_dir_header
 A directory header.
 
typedef struct cbmimage_dir_entry_s cbmimage_dir_entry
 A directory entry.
 
typedef struct cbmimage_i_dir_entry_internal_s cbmimage_i_dir_entry_internal
 internal data for directory entry
 

Enumerations

enum  cbmimage_dir_type_e {
  DIR_TYPE_DEL = 0 , DIR_TYPE_SEQ = 1 , DIR_TYPE_PRG = 2 , DIR_TYPE_USR = 3 ,
  DIR_TYPE_REL = 4 , DIR_TYPE_PART1581 = 5 , DIR_TYPE_CMD_NATIVE = 6 , DIR_TYPE_PART_OFFSET = 0x100 ,
  DIR_TYPE_PART_NO = DIR_TYPE_PART_OFFSET , DIR_TYPE_PART_CMD_NATIVE = DIR_TYPE_PART_OFFSET + 0x01 , DIR_TYPE_PART_D64 = DIR_TYPE_PART_OFFSET + 0x02 , DIR_TYPE_PART_D71 = DIR_TYPE_PART_OFFSET + 0x03 ,
  DIR_TYPE_PART_D81 = DIR_TYPE_PART_OFFSET + 0x04 , DIR_TYPE_PART_SYSTEM = DIR_TYPE_PART_OFFSET + 0xFF
}
 The type of a directory entry cbmimage_dir_entry_s. More...
 
enum  cbmimage_geos_filetype_e {
  GEOS_FILETYPE_NON_GEOS = 0x00 , GEOS_FILETYPE_BASIC = 0x01 , GEOS_FILETYPE_ASSEMBLER = 0x02 , GEOS_FILETYPE_DATA_FILE = 0x03 ,
  GEOS_FILETYPE_SYSTEM_FILE = 0x04 , GEOS_FILETYPE_DESK_ACCESSORY = 0x05 , GEOS_FILETYPE_APPLICATION = 0x06 , GEOS_FILETYPE_APPLICATION_DATA = 0x07 ,
  GEOS_FILETYPE_FONT_FILE = 0x08 , GEOS_FILETYPE_PRINTER_DRIVER = 0x09 , GEOS_FILETYPE_INPUT_DRIVER = 0x0A , GEOS_FILETYPE_DISK_DRIVER = 0x0B ,
  GEOS_FILETYPE_SYSTEM_BOOT_FILE = 0x0C , GEOS_FILETYPE_TEMPORARY = 0x0D , GEOS_FILETYPE_AUTO_EXECUTE_FILE = 0x0E
}
 The GEOS type of a directory entry cbmimage_dir_entry_s. More...
 

Functions

cbmimage_dir_headercbmimage_dir_get_header (cbmimage_fileimage *image)
 get the header entry
 
void cbmimage_dir_get_header_close (cbmimage_dir_header *header_entry)
 free the resources from a cbmimage_dir_get_header()
 
static int cbmimage_i_dir_entry_store_datetime (cbmimage_i_dir_entry_internal *dei)
 internal store date and time of directory entry @
 
static int cbmimage_i_dir_get (cbmimage_i_dir_entry_internal *dei)
 create a directory entry @
 
static int cbmimage_i_dir_get_nonempty (cbmimage_i_dir_entry_internal *dei)
 get the next non-empty directory entry @
 
cbmimage_dir_entrycbmimage_dir_get_first (cbmimage_fileimage *image)
 get the first (non-empty) directory entry
 
int cbmimage_dir_get_next (cbmimage_dir_entry *dir_entry)
 get the next (non-empty) directory entry
 
int cbmimage_dir_get_is_valid (cbmimage_dir_entry *dir_entry)
 get the next (non-empty) directory entry
 
void cbmimage_dir_get_close (cbmimage_dir_entry *dir_entry)
 free the resources from a cbmimage_dir_get_first()
 
int cbmimage_dir_is_deleted (cbmimage_dir_entry *dir_entry)
 check if the directory entry points to a deleted file
 
char * cbmimage_dir_extract_name (cbmimage_dir_header_name *dir_name, char *name_buffer, size_t name_buffer_len)
 extract the name of a directory entry as a C string
 
cbmimage_dir_entrycbmimage_i_dir_get_clone (cbmimage_dir_entry *dir_entry)
 clone a directory entry
 
int cbmimage_dir_chdir (cbmimage_dir_entry *dir_entry)
 perform a chdir to a partition marked by a directory entry
 
int cbmimage_dir_chdir_close (cbmimage_fileimage *image)
 "close a chdir"; that is, go back to the parent directory
 
int cbmimage_i_dir_get_partition_data (cbmimage_dir_entry *dir_entry, cbmimage_blockaddress *block_first, cbmimage_blockaddress *block_last, size_t *block_count)
 
int cbmimage_i_dir_set_subpartition_global (cbmimage_image_settings *settings, cbmimage_blockaddress block_subdir_first, size_t block_count)
 
int cbmimage_i_dir_set_subpartition_relative (cbmimage_image_settings *settings, cbmimage_blockaddress block_subdir_first, cbmimage_blockaddress block_subdir_last)
 

Detailed Description

Typedef Documentation

◆ cbmimage_dir_entry

A directory entry.

The functions that enumerate directory entrys all operate on this entry type.

see also: cbmimage_dir_get_first, cbmimage_dir_get_next, cbmimage_dir_get_close, cbmimage_dir_is_deleted

◆ cbmimage_dir_header

A directory header.

This entry has all the data that is needed to handle the image header and the count of free blocks

see also: cbmimage_dir_get_first, cbmimage_dir_get_next, cbmimage_dir_get_close, cbmimage_dir_is_deleted

◆ cbmimage_dir_header_name

The name of a directory header or directory entry.

This entry is used in cbmimage_dir_header as well as cbmimage_dir_entry. It describes the name of the header or directory that is to be processed.

◆ cbmimage_geos_filetype

The GEOS type of a directory entry cbmimage_dir_entry_s.

Remarks
The GEOS type is GEOS_FILETYPE_NON_GEOS if no GEOS disk was found!

◆ cbmimage_i_dir_entry_internal

internal data for directory entry

This type contains the internal data that is needed to specify a directory entry.

Remarks

Enumeration Type Documentation

◆ cbmimage_dir_type_e

The type of a directory entry cbmimage_dir_entry_s.

Enumerator
DIR_TYPE_DEL 

this directory entry is for a file that is deleted

DIR_TYPE_SEQ 

this directory entry is for a SEQuential file

DIR_TYPE_PRG 

this directory entry is for a PRogRamm file

DIR_TYPE_USR 

this directory entry is for a USeR file

DIR_TYPE_REL 

this directory entry is for a RELative file

DIR_TYPE_PART1581 

this directory entry is for a 1581 style partition file (D81, D1M, D2M, D4M only)

DIR_TYPE_CMD_NATIVE 

this directory entry is for a CMD NATive partition (D1M, D2M, D4M only)

◆ cbmimage_geos_filetype_e

The GEOS type of a directory entry cbmimage_dir_entry_s.

Remarks
The GEOS type is GEOS_FILETYPE_NON_GEOS if no GEOS disk was found!
Enumerator
GEOS_FILETYPE_NON_GEOS 

no GEOS file

GEOS_FILETYPE_BASIC 

a BASIC file

GEOS_FILETYPE_ASSEMBLER 

an assembler file

GEOS_FILETYPE_DATA_FILE 

a data file

GEOS_FILETYPE_SYSTEM_FILE 

a system file

GEOS_FILETYPE_DESK_ACCESSORY 

a file for a GEOS desk accessory

GEOS_FILETYPE_APPLICATION 

a file for a GEOS application

GEOS_FILETYPE_APPLICATION_DATA 

some user-created document from a GEOS application or desk accessory

GEOS_FILETYPE_FONT_FILE 

a GEOS font

GEOS_FILETYPE_PRINTER_DRIVER 

a GEOS printer driver

GEOS_FILETYPE_INPUT_DRIVER 

a GEOS input driver

GEOS_FILETYPE_DISK_DRIVER 

a GEOS disk driver or disk device

GEOS_FILETYPE_SYSTEM_BOOT_FILE 

a GEOS system boot file

GEOS_FILETYPE_TEMPORARY 

a GEOS temporary file. Will be deleted on termination of the program

GEOS_FILETYPE_AUTO_EXECUTE_FILE 

a GEOS auto-execute file

Function Documentation

◆ cbmimage_dir_chdir()

int cbmimage_dir_chdir ( cbmimage_dir_entry * dir_entry)

perform a chdir to a partition marked by a directory entry

Parameters
[in]dir_entrypointer to a directory entry that was the result of a previous cbmimage_dir_get_first() or cbmimage_dir_get_next() call.
Returns
  • 0 on success
  • != 0 otherwise

◆ cbmimage_dir_chdir_close()

int cbmimage_dir_chdir_close ( cbmimage_fileimage * image)

"close a chdir"; that is, go back to the parent directory

Parameters
[in]imagepointer to an image for which to return to the parent directory
Returns
  • 0 on success
  • != 0 otherwise
Remarks
If no parent exists, this functions returns with an error

◆ cbmimage_dir_extract_name()

char * cbmimage_dir_extract_name ( cbmimage_dir_header_name * dir_name,
char * name_buffer,
size_t name_buffer_len )

extract the name of a directory entry as a C string

Parameters
[in]dir_namepointer to the name entry of a cbmimage_dir_entry or cbmimage_header_entry
[in,out]name_bufferpointer to a block of memory that acts as a buffer for the name as a C string
[in]name_buffer_lenthe length of the buffer provided by the parameter name. This must be at least 18 for a regular directory entry, and at least 26 for the header
Returns
pointer to the extra text after the name
Remarks
  • Example: A{SHIFT-SPACE},8,1 would be output as "A",8,1 by CBM DOS. This function would give the string A{NUL},8,1{NUL} in the buffer pointed to by name, and the return value would point to the ,8,1 part.

◆ cbmimage_dir_get_close()

void cbmimage_dir_get_close ( cbmimage_dir_entry * dir_entry)

free the resources from a cbmimage_dir_get_first()

Parameters
[in]dir_entryptr to a directory entry that was the result of a previous cbmimage_dir_get_first() or cbmimage_dir_get_next() call.
Remarks
  • This function frees the associated resources to the given pointer.
  • After return, it is not allowed anymore to access the data pointed to by dir_entry.

◆ cbmimage_dir_get_first()

cbmimage_dir_entry * cbmimage_dir_get_first ( cbmimage_fileimage * image)

get the first (non-empty) directory entry

Parameters
[in]imagepointer to the image data
Returns
A pointer to the directory entry.
If there is none, it returns 0.
Remarks
  • the structure obtained by this function has to be freed by cbmimage_dir_get_close() once the processing is done.
  • If needed, this function reads in the next block or blocks of the directory until it finds a non-empty entry, or the last directory entry has been checked.
  • After the call, the pointer to the directory entry is advanced to the next one after the one returned.
  • Subsequent entries can be obtained with a call to cbmimage_dir_get_next().
  • If the directory processing is done, the returned pointer and associated resources must be freed with a call to cbmimage_dir_get_close().

◆ cbmimage_dir_get_header()

cbmimage_dir_header * cbmimage_dir_get_header ( cbmimage_fileimage * image)

get the header entry

Parameters
[in]imagepointer to the image data
Returns
A pointer to the header entry. If there is no header (partition table), the pointer will be NULL.
Remarks

◆ cbmimage_dir_get_header_close()

void cbmimage_dir_get_header_close ( cbmimage_dir_header * header_entry)

free the resources from a cbmimage_dir_get_header()

Parameters
[in]header_entryptr to a header entry that was the result of a previous call to cbmimage_dir_get_header().
Remarks
  • This function frees the associated resources to the given pointer.
  • After return, it is not allowed anymore to access the data pointed to by header_entry.

◆ cbmimage_dir_get_is_valid()

int cbmimage_dir_get_is_valid ( cbmimage_dir_entry * dir_entry)

get the next (non-empty) directory entry

Parameters
[in]dir_entryptr to a directory entry that was the result of a previous cbmimage_dir_get_first() or cbmimage_dir_get_next() call.
On return, this dir_entry contains the next directory entry if the return value is 0. If the return value is not 0, The result of this is unspecified.
Returns
  • 0 on success
  • != 0 if there are no more directory entries

◆ cbmimage_dir_get_next()

int cbmimage_dir_get_next ( cbmimage_dir_entry * dir_entry)

get the next (non-empty) directory entry

Parameters
[in,out]dir_entryptr to a directory entry that was the result of a previous cbmimage_dir_get_first() or cbmimage_dir_get_next() call.
On return, this dir_entry contains the next directory entry if the return value is 0. If the return value is not 0, The result of this is unspecified.
Returns
  • 0 on success
  • -1 if there are no more directory entries
Remarks
  • If needed, this function reads in the next block or blocks of the directory until it finds a non-empty entry, or the last directory entry has been checked.
  • Subsequent entries can be obtained with another call to cbmimage_dir_get_next().
  • If the directory processing is done, the returned pointer and associated resources must be freed with a call to cbmimage_dir_get_close().

◆ cbmimage_dir_is_deleted()

int cbmimage_dir_is_deleted ( cbmimage_dir_entry * dir_entry)

check if the directory entry points to a deleted file

Parameters
[in]dir_entrypointer to a directory entry that was the result of a previous cbmimage_dir_get_first() or cbmimage_dir_get_next() call.
Returns
  • 0 if this directory entry is empty
  • != 0 otherwise
Remarks
  • An entry is considered empty/deleted if the CBM DOS file type is 0.
    That is, not only does it have to have DIR_TYPE_DEL, but also is_locked and is_closed must not be set.
    This is exactly the same semantincs as applied by CBM DOS.

◆ cbmimage_i_dir_entry_store_datetime()

static int cbmimage_i_dir_entry_store_datetime ( cbmimage_i_dir_entry_internal * dei)
static

internal store date and time of directory entry @

Parameters
[in,out]deiptr to a internal directory entry that will be initialized
Returns
  • 0 on success
  • -1 if there are no more directory entries
Remarks
  • If the file has a date and time, the values of the directory entry are modified to reflect these.
    If not, the values of the directory entry are cleared.

◆ cbmimage_i_dir_get()

static int cbmimage_i_dir_get ( cbmimage_i_dir_entry_internal * dei)
static

create a directory entry @

Parameters
[in,out]deiptr to a internal directory entry that will be initialized
Returns
  • 0 on success
  • -1 if there are no more directory entries
Remarks
  • If needed, this function reads in the next block of the directory
  • After the call, the pointer to the directory entry is advanced to the next one

◆ cbmimage_i_dir_get_clone()

cbmimage_dir_entry * cbmimage_i_dir_get_clone ( cbmimage_dir_entry * dir_entry)

clone a directory entry

Parameters
[in]dir_entryptr to a directory entry that was the result of a previous cbmimage_dir_get_first() or cbmimage_dir_get_next() call.
Returns
pointer to a copy of the dir_entry
Remarks

◆ cbmimage_i_dir_get_nonempty()

static int cbmimage_i_dir_get_nonempty ( cbmimage_i_dir_entry_internal * dei)
static

get the next non-empty directory entry @

Parameters
[in,out]deiptr to a internal directory entry that will be initialized
Returns
  • 0 on success
  • -1 if there are no more directory entries
Remarks
  • If needed, this function reads in the next block or blocks of the directory until it finds a non-empty entry, or the last directory entry has been checked.
  • After the call, the pointer to the directory entry is advanced to the next one after the one returned.

◆ cbmimage_i_dir_get_partition_data()

int cbmimage_i_dir_get_partition_data ( cbmimage_dir_entry * dir_entry,
cbmimage_blockaddress * block_first,
cbmimage_blockaddress * block_last,
size_t * block_count )

read the partition data (start and end block) from a directory entry

Parameters
[in]dir_entrypointer to a entry
[in,out]block_firstpointer to a block address that will contain the first block of the partition on exit
[in,out]block_lastpointer to a block address that will contain the last block of the partition on exit.
Can be NULL if this info is not needed.
[in,out]block_countpointer to a size_t that will contain the number of blocks of this partition on exit.
Can be NULL if this info is not needed.
Returns
  • 0 on success
  • != 0 otherwise
Remarks
The info block_last and block_count is somewhat redundant. That is, block_first + block_count = block_last. However, for different purposes, the one or the other info is needed, so this function returns both variants.

◆ cbmimage_i_dir_set_subpartition_global()

int cbmimage_i_dir_set_subpartition_global ( cbmimage_image_settings * settings,
cbmimage_blockaddress block_subdir_first,
size_t block_count )

change to a (global) subpartition

Parameters
[in]settingspointer to image settings
[in]block_subdir_firstthe block that is the first block of the subdir/subpartition
[in,out]block_countthe number of blocks that form this subdir/subpartition
Returns
  • 0 on success
  • -1 if an error occurred
Remarks
A global subpartition/subdir is a subdir where the first block inside of the subpartition has the address T/S 1/0 (LBA 1). That is, the whole addressing schema is changed.

This is the type of partitions that was introduced with the CMD devices

◆ cbmimage_i_dir_set_subpartition_relative()

int cbmimage_i_dir_set_subpartition_relative ( cbmimage_image_settings * settings,
cbmimage_blockaddress block_subdir_first,
cbmimage_blockaddress block_subdir_last )

change to a (relative) subpartition

Parameters
[in]settingspointer to image settings
[in]block_subdir_firstthe block that is the first block of the subdir/subpartition
[in,out]block_subdir_lastthe last block of the subdir/subpartition
Returns
  • 0 on success
  • -1 if an error occurred
Remarks
A relative subpartition/subdir is a subdir where the first block inside of the subpartition has the same address as it has in the "surrounding" image. That is, block x/y is also addresses as x/y inside of the subpartition.

This is the type of partitions that was introduced with the 1581 drive.

Todo
Change the input parameter block_subdir_last to block_count to be consistent with cbmimage_i_dir_set_subpartition_global()