### Complete Example: Managing Hard-Links on an ISO Source: https://clalancette.github.io/pycdlib/example-managing-hard-links.html This comprehensive example demonstrates adding a file, creating a hard-link, removing a hard-link from a specific context, and writing the ISO. It illustrates how to control file visibility across ISO9660 and Joliet. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new(joliet=3) foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1', joliet_path='/foo') iso.add_hard_link(iso_old_path='/FOO.;1', iso_new_path='/BAR.;1') iso.rm_hard_link(joliet_path='/foo') outiso = BytesIO() iso.write_fp(outiso) iso.close() ``` -------------------------------- ### Example output for subdirectory walk Source: https://clalancette.github.io/pycdlib/example-walking-iso-filesystem.html Expected console output when walking from the /DIR1 directory. ```text Dirname: /DIR1 , Dirlist: [] , Filelist: ['FOO.;1', 'BAR.;1'] ``` -------------------------------- ### Example output for root walk Source: https://clalancette.github.io/pycdlib/example-walking-iso-filesystem.html Expected console output when walking from the root directory. ```text Dirname: / , Dirlist: ['DIR2', 'DIR1'] , Filelist: [] Dirname: /DIR1 , Dirlist: [] , Filelist: ['FOO.;1', 'BAR.;1'] Dirname: /DIR2 , Dirlist: [] , Filelist: ['BAZ.;1'] ``` -------------------------------- ### Create a bootable El Torito ISO Source: https://clalancette.github.io/pycdlib/example-creating-bootable-iso.html A complete example showing the full workflow for creating a bootable ISO image. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new() bootstr = b'boot\n' iso.add_fp(BytesIO(bootstr), len(bootstr), '/BOOT.;1') iso.add_eltorito('/BOOT.;1') iso.write('eltorito.iso') iso.close() ``` -------------------------------- ### Walk the ISO filesystem Source: https://clalancette.github.io/pycdlib/example-walking-iso-filesystem.html Complete example demonstrating the creation of an ISO, adding directories and files, and using the walk API to iterate through the filesystem. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new() iso.add_directory('/DIR1') foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/DIR1/FOO.;1') barstr = b'bar\n' iso.add_fp(BytesIO(barstr), len(barstr), '/DIR1/BAR.;1') iso.add_directory('/DIR2') bazstr = b'baz\n' iso.add_fp(BytesIO(bazstr), len(bazstr), '/DIR2/BAZ.;1') for dirname, dirlist, filelist in iso.walk(iso_path='/'): print("Dirname:", dirname, ", Dirlist:", dirlist, ", Filelist:", filelist) for dirname, dirlist, filelist in iso.walk(iso_path='/DIR1'): print("Dirname:", dirname, ", Dirlist:", dirlist, ", Filelist:", filelist) iso.close() ``` -------------------------------- ### Create a UDF ISO image Source: https://clalancette.github.io/pycdlib/example-creating-udf-iso.html A complete example demonstrating the initialization, file addition, and writing process for a UDF-enabled ISO. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new(udf='2.60') foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1', udf_path='/foo') iso.add_directory('/DIR1', udf_path='/dir1') iso.write('new.iso') iso.close() ``` -------------------------------- ### Create a New Basic ISO with pycdlib Source: https://clalancette.github.io/pycdlib/example-creating-new-basic-iso.html Use this example to create a new ISO image with no extensions. It demonstrates adding a file from a BytesIO object and a directory. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new() foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1') iso.add_directory('/DIR1') iso.write('new.iso') iso.close() ``` -------------------------------- ### Create an ISO with Rock Ridge Extensions Source: https://clalancette.github.io/pycdlib/example-creating-rock-ridge-iso.html A complete example showing the full workflow for creating a Rock Ridge enabled ISO image. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new(rock_ridge='1.09') foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1', rr_name='foo') iso.add_directory('/DIR1', rr_name='dir1') iso.write('new.iso') iso.close() ``` -------------------------------- ### Iterate over the ISO root Source: https://clalancette.github.io/pycdlib/example-walking-iso-filesystem.html Use the walk API to traverse the entire ISO filesystem starting from the root. ```python for dirname, dirlist, filelist in iso.walk(iso_path='/'): print("Dirname:", dirname, ", Dirlist:", dirlist, ", Filelist:", filelist) ``` -------------------------------- ### Add Boot File to ISO Source: https://clalancette.github.io/pycdlib/example-creating-hybrid-bootable-iso.html Adds a file named '/BOOT.;1' to the ISO with specific boot start sequence content conforming to isolinux specifications. This file is a minimal requirement for booting. ```python isolinuxstr = b'\x00'*0x40 + b'\xfb\xc0\x78\x70' iso.add_fp(BytesIO(isolinuxstr), len(isolinuxstr), '/BOOT.;1') ``` -------------------------------- ### Get ISO9660 Facade Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Returns a facade for simplified manipulation of the ISO9660 portions of the ISO. ```APIDOC ## GET /facade/iso9660 ### Description Returns a 'facade' that simplifies some of the complexities of the PyCdlib class, while giving up some of the full power. This facade only allows manipulation of the ISO9660 portions of the ISO. ### Method GET ### Endpoint /facade/iso9660 ### Parameters None. ### Response #### Success Response (200) - **facade** (object) - A PyCdlibISO9660 object that can be used to interact with the ISO. #### Response Example ```json { "facade": "" } ``` ``` -------------------------------- ### Get Joliet Facade Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Returns a facade for simplified manipulation of the Joliet portions of the ISO. ```APIDOC ## GET /facade/joliet ### Description Returns a 'facade' that simplifies some of the complexities of the PyCdlib class, while giving up some of the full power. This facade only allows manipulation of the Joliet portions of the ISO. ### Method GET ### Endpoint /facade/joliet ### Parameters None. ### Response #### Success Response (200) - **facade** (object) - A PyCdlibJoliet object that can be used to interact with the ISO. #### Response Example ```json { "facade": "" } ``` ``` -------------------------------- ### Get File from ISO Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Fetches a single file from the ISO and writes it to a local file. ```APIDOC ## POST /file/get_from_iso ### Description Fetches a single file from the ISO and writes it out to a local file. ### Method POST ### Endpoint /file/get_from_iso ### Parameters #### Request Body - **local_path** (string) - Required - The local file to write to. - **blocksize** (integer) - Optional - The number of bytes in each transfer. - **iso_path** (string) - Optional - The absolute ISO9660 path to lookup on the ISO (exclusive with rr_path, joliet_path, and udf_path). - **rr_path** (string) - Optional - The absolute Rock Ridge path to lookup on the ISO (exclusive with iso_path, joliet_path, and udf_path). - **joliet_path** (string) - Optional - The absolute Joliet path to lookup on the ISO (exclusive with iso_path, rr_path, and udf_path). - **udf_path** (string) - Optional - The absolute UDF path to lookup on the ISO (exclusive with iso_path, rr_path, and joliet_path). ### Response #### Success Response (200) - **message** (string) - Indicates successful file retrieval and writing. #### Response Example ```json { "message": "File successfully retrieved from ISO and written to local path." } ``` ``` -------------------------------- ### Iterate over a specific subdirectory Source: https://clalancette.github.io/pycdlib/example-walking-iso-filesystem.html Use the walk API to traverse starting from a specific subdirectory. ```python for dirname, dirlist, filelist in iso.walk(iso_path='/DIR1'): print("Dirname:", dirname, ", Dirlist:", dirlist, ", Filelist:", filelist) ``` -------------------------------- ### Initialize PyCdlib and Create New ISO Source: https://clalancette.github.io/pycdlib/example-creating-hybrid-bootable-iso.html Initializes a PyCdlib object and creates a new, basic ISO structure. This is the starting point for building any ISO image. ```python iso = pycdlib.PyCdlib() iso.new() ``` -------------------------------- ### Get File from ISO to File Pointer Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Fetches a single file from the ISO and writes it out to the file object. ```APIDOC ## POST /file/get_from_iso_fp ### Description Fetches a single file from the ISO and writes it out to the file object. ### Method POST ### Endpoint /file/get_from_iso_fp ### Parameters #### Request Body - **outfp** (file object) - Required - The file object to write data to. - **blocksize** (integer) - Optional - The number of bytes in each transfer. - **iso_path** (string) - Optional - The absolute ISO9660 path to lookup on the ISO (exclusive with rr_path, joliet_path, and udf_path). - **rr_path** (string) - Optional - The absolute Rock Ridge path to lookup on the ISO (exclusive with iso_path, joliet_path, and udf_path). - **joliet_path** (string) - Optional - The absolute Joliet path to lookup on the ISO (exclusive with iso_path, rr_path, and udf_path). - **udf_path** (string) - Optional - The absolute UDF path to lookup on the ISO (exclusive with iso_path, rr_path, and joliet_path). ### Response #### Success Response (200) - **message** (string) - Indicates successful file retrieval and writing to file object. #### Response Example ```json { "message": "File successfully retrieved from ISO and written to file object." } ``` ``` -------------------------------- ### Get and Write File (Deprecated) Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Fetches a single file from the ISO and writes it to a local file. Deprecated in favor of get_file_from_iso. ```APIDOC ## POST /file/get_and_write (Deprecated) ### Description Fetches a single file from the ISO and writes it to the specified local file. This method is deprecated. ### Method POST ### Endpoint /file/get_and_write ### Parameters #### Request Body - **iso_path** (string) - Required - The absolute path to the file to get data from. - **local_path** (string) - Required - The local filename to write the contents to. - **blocksize** (integer) - Optional - The blocksize to use when copying data; the default is 8192. ### Response #### Success Response (200) - **message** (string) - Indicates successful file fetch and write. #### Response Example ```json { "message": "File successfully written to local path." } ``` ``` -------------------------------- ### Get and Write File to File Pointer (Deprecated) Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Fetches a single file from the ISO and writes it to a file object. Deprecated in favor of get_file_from_iso_fp. ```APIDOC ## POST /file/get_and_write_fp (Deprecated) ### Description Fetches a single file from the ISO and writes it to the provided file object. This method is deprecated. ### Method POST ### Endpoint /file/get_and_write_fp ### Parameters #### Request Body - **iso_path** (string) - Required - The absolute path to the file to get data from. - **outfp** (file object) - Required - The file object to write data to. - **blocksize** (integer) - Optional - The blocksize to use when copying data; the default is 8192. ### Response #### Success Response (200) - **message** (string) - Indicates successful file fetch and write to file object. #### Response Example ```json { "message": "File successfully written to file object." } ``` ``` -------------------------------- ### Initialize ISO and add file Source: https://clalancette.github.io/pycdlib/example-reading-file-in-chunks.html Creates a new ISO instance and adds a byte string as a file. ```python iso = pycdlib.PyCdlib() iso.new() foostr = b'foofoo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1') ``` -------------------------------- ### Initialize PyCdlib and Create New ISO Source: https://clalancette.github.io/pycdlib/example-forcing-consistency.html Create a new `PyCdlib` object and initialize a new ISO image with no extensions. ```python iso = pycdlib.PyCdlib() iso.new() ``` -------------------------------- ### Get Entry (Deprecated) Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Retrieves the directory record for a given path. Deprecated in favor of get_record. ```APIDOC ## GET /entry/get (Deprecated) ### Description Gets the directory record for a particular path. This method is deprecated. ### Method GET ### Endpoint /entry/get ### Parameters #### Query Parameters - **iso_path** (string) - Required - The path on the ISO to look up information for. - **joliet** (boolean) - Optional - Whether to look for the path in the Joliet portion of the ISO. Defaults to false. ### Response #### Success Response (200) - **directory_record** (object) - A dr.DirectoryRecord object representing the path. #### Response Example ```json { "directory_record": { "name": "example.txt", "size": 1024, "type": "file" } } ``` ``` -------------------------------- ### Create ISO with Initial File Source: https://clalancette.github.io/pycdlib/example-modifying-file-in-place.html Creates a new ISO image and adds an initial file '/FOO.;1' with 'foo\n' content, writing it to an in-memory BytesIO object. ```python iso = pycdlib.PyCdlib() iso.new() foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1') outiso = BytesIO() iso.write_fp(outiso) iso.close() ``` -------------------------------- ### Add directories and files to the ISO Source: https://clalancette.github.io/pycdlib/example-walking-iso-filesystem.html Populate the ISO with directories and file content provided as byte strings. ```python iso.add_directory('/DIR1') foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/DIR1/FOO.;1') barstr = b'bar\n' iso.add_fp(BytesIO(barstr), len(barstr), '/DIR1/BAR.;1') iso.add_directory('/DIR2') bazstr = b'baz\n' iso.add_fp(BytesIO(bazstr), len(bazstr), '/DIR2/BAZ.;1') ``` -------------------------------- ### Get Full Path from Directory Record Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Retrieves the absolute path of a file given its directory record. ```APIDOC ## GET /dirrecord/fullpath ### Description Gets the absolute path of a directory record on the ISO. ### Method GET ### Endpoint /dirrecord/fullpath ### Parameters #### Query Parameters - **rec** (object) - Required - The directory record to get the full path for. - **rockridge** (boolean) - Optional - Whether to get the Rock Ridge full path. Defaults to false. ### Response #### Success Response (200) - **full_path** (string) - A string representing the absolute path to the file on the ISO. #### Response Example ```json { "full_path": "/path/to/directory/file.txt" } ``` ``` -------------------------------- ### Read a large file from an ISO in chunks Source: https://clalancette.github.io/pycdlib/example-reading-file-in-chunks.html Demonstrates the complete workflow for creating an ISO, adding a file, and reading it back using the open_file_from_iso context manager. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new() foostr = b'foofoo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1') with iso.open_file_from_iso(iso_path='/FOO.;1') as infp: all1 = infp.read() infp.seek(0) first = infp.read(3) second = infp.read() iso.close() ``` -------------------------------- ### Create New ISO with Joliet Support Source: https://clalancette.github.io/pycdlib/example-using-facade.html Initialize a new PyCdlib object and create a new ISO image with Joliet file system support enabled by passing `joliet=3`. ```python iso = pycdlib.PyCdlib() iso.new(joliet=3) ``` -------------------------------- ### Configure El Torito Booting Source: https://clalancette.github.io/pycdlib/example-creating-hybrid-bootable-iso.html Configures the ISO to be El Torito bootable using '/BOOT.;1' as the boot file. Sets the `boot_load_size` to 4 sectors (512 bytes each), a common value for initial boot loading. ```python iso.add_eltorito('/BOOT.;1', boot_load_size=4) ``` -------------------------------- ### Initialize PyCdlib Object Source: https://clalancette.github.io/pycdlib/example-creating-rock-ridge-iso.html Create a new ISO instance with Rock Ridge version 1.09 enabled. ```python iso = pycdlib.PyCdlib() iso.new(rock_ridge='1.09') ``` -------------------------------- ### Add a boot file to the ISO Source: https://clalancette.github.io/pycdlib/example-creating-bootable-iso.html Add a file to the ISO that will serve as the boot data. ```python bootstr = b'boot\n' iso.add_fp(BytesIO(bootstr), len(bootstr), '/BOOT.;1') ``` -------------------------------- ### POST /open Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Opens an existing ISO file for inspection and modification. ```APIDOC ## POST /open ### Description Opens an existing ISO file for inspection and modification. ### Method POST ### Endpoint /open ### Parameters #### Query Parameters - **filename** (string) - Required - The filename containing the ISO to open. - **mode** (string) - Optional - The mode to use when opening the ISO file. Defaults to 'rb'. ### Returns Nothing. ``` -------------------------------- ### Bootable CD Options (Alpha, HPPA, MIPS) Source: https://clalancette.github.io/pycdlib/pycdlib-genisoimage.html Options for creating bootable CDs for Alpha, HPPA, and MIPS architectures. ```APIDOC ## OPTIONS ### Description Options for creating bootable CDs for Alpha, HPPA, and MIPS architectures. ### Method N/A (Command-line options) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response None ## -alpha-boot _alpha_boot_image_ ### Description (not supported by pycdlib-genisoimage) Specifies the path and filename of the boot image to be used when making an Alpha/SRM bootable CD. The pathname must be relative to the source path specified to **pycdlib-genisoimage**. ## -hppa-bootloader _hppa_bootloader_image_ ### Description (not supported by pycdlib-genisoimage) Specifies the path and filename of the boot image to be used when making an HPPA bootable CD. The pathname must be relative to the source path specified to **pycdlib-genisoimage**. Other options are required, at the very least a kernel filename and a boot command line. ## -hppa-cmdline _hppa_boot_command_line_ ### Description (not supported by pycdlib-genisoimage) Specifies the command line to be passed to the HPPA boot loader when making a bootable CD. Separate the parameters with spaces or commas. More options must be passed to **pycdlib-genisoimage,** at the very least a kernel filename and the boot loader filename. ## -hppa-kernel-32 _hppa_kernel_32_ / -hppa-kernel-64 _hppa_kernel_64_ ### Description (not supported by pycdlib-genisoimage) Specifies the path and filename of the 32-bit and/or 64-bit kernel images to be used when making an HPPA bootable CD. The pathnames must be relative to the source path specified to **pycdlib-genisoimage**. Other options are required, at the very least the boot loader filename and the boot command line. ## -hppa-ramdisk _hppa_ramdisk_image_ ### Description (not supported by pycdlib-genisoimage) Specifies the path and filename of the ramdisk image to be used when making an HPPA bootable CD. The pathname must be relative to the source path specified to **pycdlib-genisoimage**. This parameter is optional. Other options are required, at the very least a kernel filename and the boot command line. ## -mips-boot _mips_boot_image_ ### Description (not supported by pycdlib-genisoimage) Specifies the path and filename of the boot image to be used when making an SGI/big-endian MIPS bootable CD. The pathname must be relative to the source path specified to **pycdlib-genisoimage**. This option may be specified several times, to store up to 15 boot images. ## -mipsel-boot _mipsel_boot_image_ ### Description (not supported by pycdlib-genisoimage) Specifies the path and filename of the boot image to be used when making an SGI/little-endian MIPS bootable CD. The pathname must be relative to the source path specified to **pycdlib-genisoimage**. ``` -------------------------------- ### Configure El Torito boot settings Source: https://clalancette.github.io/pycdlib/example-creating-bootable-iso.html Enable El Torito boot functionality using the previously added boot file. ```python iso.add_eltorito('/BOOT.;1') ``` -------------------------------- ### Create Hybrid Bootable ISO with pycdlib Source: https://clalancette.github.io/pycdlib/example-creating-hybrid-bootable-iso.html This snippet creates a hybrid bootable ISO file named 'eltorito.iso'. It includes adding a boot file, configuring El Torito booting, and enabling hybrid ISO functionality. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new() bootstr = b'boot\n' iso.add_fp(BytesIO(bootstr), len(bootstr), '/BOOT.;1') iso.add_eltorito('/BOOT.;1') iso.add_isohybrid() iso.write('eltorito.iso') iso.close() ``` -------------------------------- ### ISO Creation Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Method for creating a new ISO 9660 filesystem from scratch. ```APIDOC ## POST /new ### Description Creates a new ISO 9660 filesystem from scratch with specified parameters. ### Method POST ### Endpoint /new ### Parameters #### Request Body - **interchange_level** (integer) - Optional - The ISO9660 interchange level (1-4). Defaults to 1. - **sys_ident** (string) - Optional - System identifier. - **vol_ident** (string) - Optional - Volume identifier. - **set_size** (integer) - Optional - Number of volumes in the set. Defaults to 1. - **seqnum** (integer) - Optional - Sequence number of the volume. Defaults to 1. - **log_block_size** (integer) - Optional - Logical block size. Defaults to 2048. - **vol_set_ident** (string) - Optional - Volume set identifier. - **pub_ident_str** (string) - Optional - Publisher identifier. - **preparer_ident_str** (string) - Optional - Preparer identifier. - **app_ident_str** (string) - Optional - Application identifier. - **copyright_file** (string) - Optional - Path to the copyright file. - **abstract_file** (string) - Optional - Path to the abstract file. - **bibli_file** (string) - Optional - Path to the bibliographic file. - **vol_expire_date** (string) - Optional - Volume expiration date (format depends on ISO standard). - **app_use** (string) - Optional - Application use field. - **joliet** (boolean) - Optional - Enable Joliet extensions. - **rock_ridge** (boolean) - Optional - Enable Rock Ridge extensions. - **xa** (boolean) - Optional - Enable XA extensions. Defaults to False. - **udf** (boolean) - Optional - Enable UDF extensions. ``` -------------------------------- ### Add File using Joliet Facade Source: https://clalancette.github.io/pycdlib/example-using-facade.html Add a file to the ISO from a byte string using the Joliet facade's `add_fp` method. Only the `joliet_path` is required. ```python foostr = b'foo\n' joliet.add_fp(BytesIO(foostr), len(foostr), joliet_path='/foo') ``` -------------------------------- ### Enable Hybrid ISO Functionality Source: https://clalancette.github.io/pycdlib/example-creating-hybrid-bootable-iso.html Adds the boot file to the system use area, transforming the ISO into a hybrid bootable image. This allows booting from both CDs (via El Torito) and USB drives. ```python iso.add_isohybrid() ``` -------------------------------- ### Initialize a new UDF ISO object Source: https://clalancette.github.io/pycdlib/example-creating-udf-iso.html Create a PyCdlib instance and initialize it with UDF version 2.60. ```python iso = pycdlib.PyCdlib() iso.new(udf='2.60') ``` -------------------------------- ### Create a New ISO Image Source: https://clalancette.github.io/pycdlib/example-creating-new-basic-iso.html Use the new() method to create a new ISO image. Passing no arguments results in a basic interchange level 1 ISO with no extensions. ```python iso.new() ``` -------------------------------- ### Add Directory using Joliet Facade Source: https://clalancette.github.io/pycdlib/example-using-facade.html Create a new directory on the ISO using the Joliet facade's `add_directory` method, specifying only the `joliet_path`. ```python joliet.add_directory(joliet_path='/dir1') ``` -------------------------------- ### Open file from ISO Source: https://clalancette.github.io/pycdlib/example-reading-file-in-chunks.html Opens a file within the ISO using a context manager. ```python with iso.open_file_from_iso(iso_path='/FOO.;1') as infp: ``` -------------------------------- ### PyCdlib Class Methods Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Methods for adding directories, files, and boot records to an ISO image. ```APIDOC ## add_directory ### Description Adds a directory to the ISO image. ### Parameters #### Path Parameters - **iso_path** (string) - Optional - The ISO9660 absolute path. - **rr_name** (string) - Optional - The Rock Ridge name. - **joliet_path** (string) - Optional - The Joliet absolute path. - **file_mode** (int) - Optional - POSIX file mode for Rock Ridge. - **udf_path** (string) - Optional - The UDF absolute path. ## add_file ### Description Adds a file to the ISO image from a local path. ### Parameters - **filename** (string) - Required - The local filename. - **iso_path** (string) - Optional - The ISO9660 destination path. - **rr_name** (string) - Optional - The Rock Ridge name. - **joliet_path** (string) - Optional - The Joliet destination path. - **file_mode** (int) - Optional - POSIX file mode. - **udf_path** (string) - Optional - The UDF destination path. ## add_eltorito ### Description Adds an El Torito Boot Record to the ISO. ### Parameters - **bootfile_path** (string) - Required - Path to the boot file on the ISO. - **platform_id** (int) - Optional - Platform ID (0=x86, 1=PPC, 2=Mac, 0xef=UEFI). - **bootable** (bool) - Optional - Whether the media is bootable. ``` -------------------------------- ### POST /open_fp Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Opens an existing ISO for inspection and modification using a file pointer. ```APIDOC ## POST /open_fp ### Description Opens an existing ISO for inspection and modification using a file object (file pointer). The file object must remain open for the lifetime of the PyCdlib object. ### Method POST ### Endpoint /open_fp ### Parameters #### Request Body Parameters - **fp** (file object) - Required - The file object containing the ISO to open. ### Returns Nothing. ``` -------------------------------- ### Add a directory to the ISO Source: https://clalancette.github.io/pycdlib/example-creating-udf-iso.html Create a directory on the ISO with a corresponding UDF path. ```python iso.add_directory('/DIR1', udf_path='/dir1') ``` -------------------------------- ### Add File with ISO and Joliet Paths Source: https://clalancette.github.io/pycdlib/example-managing-hard-links.html Add a file to the ISO, specifying both its ISO9660 path ('/FOO.;1') and its Joliet path ('/foo'). This implicitly creates links in both contexts. ```python foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1', joliet_path='/foo') ``` -------------------------------- ### Open and List Files in an ISO Source: https://clalancette.github.io/pycdlib/example-opening-existing-iso.html Opens an existing ISO file specified by a command-line argument and prints the identifiers of all files and directories at the root. Requires the sys module for argument access. The open method parses ISO metadata, which may take time for network files. An alternative open_fp method accepts file-like objects. ```python import sys import pycdlib iso = pycdlib.PyCdlib() iso.open(sys.argv[1]) for child in iso.list_children(iso_path='/'): print(child.file_identifier()) iso.close() ``` ```python import sys import pycdlib ``` ```python iso = pycdlib.PyCdlib() iso.open(sys.argv[1]) ``` ```python for child in iso.list_children(iso_path='/'): print(child.file_identifier()) ``` ```python iso.close() ``` -------------------------------- ### add_isohybrid Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Makes an ISO 'hybrid', allowing it to be booted from CD or USB. Requires El Torito support and a specific boot image signature. ```APIDOC ## add_isohybrid ### Description Make an ISO a 'hybrid', which means that it can be booted either from a CD or from more traditional media (like a USB stick). This requires that the ISO already have El Torito, and will use the El Torito boot file as a bootable image. That image must contain a certain signature in order to work as a hybrid (if using syslinux, this generally means the isohdpfx.bin files). ### Method (Implicitly a method of a PyCdlib object, likely POST or PUT conceptually) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body (Parameters are passed as keyword arguments) - **part_entry** (integer) - The partition entry to use; one by default. - **mbr_id** (string) - The mbr_id to use. If set to None (the default), a random one will be generated. - **part_offset** (integer) - The partition offset to use; zero by default. - **geometry_sectors** (integer) - The number of sectors to assign; thirty-two by default. - **geometry_heads** (integer) - The number of heads to assign; sixty-four by default. - **part_type** (integer) - The partition type to assign; twenty-three by default, but will automatically be set to 0 if mac or efi are True. - **mac** (boolean) - Add support for Mac; False by default. - **efi** (boolean) - Add support for EFI; False by default, but will automatically be set to True if mac is True. ### Request Example ```python # Assuming 'iso' is a PyCdlib object iso.add_isohybrid(mac=True, efi=True) ``` ### Response #### Success Response (200) - **None** - This method does not return any value upon success. ``` -------------------------------- ### Access ISO Aspects with Joliet Facade Source: https://clalancette.github.io/pycdlib/example-using-facade.html Use the Joliet facade to simplify adding files and directories to an ISO. Files added via the facade are only visible in the Joliet context. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new(joliet=3) joliet = iso.get_joliet_facade() foostr = b'foo\n' joliet.add_fp(BytesIO(foostr), len(foostr), joliet_path='/foo') joliet.add_directory(joliet_path='/dir1') iso.write('new.iso') iso.close() ``` -------------------------------- ### POST /open_file_from_iso Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Opens a file within an ISO for reading in a context manager. ```APIDOC ## POST /open_file_from_iso ### Description Opens a file for reading within an ISO image using a context manager. This allows for chunked reading of the file. ### Method POST ### Endpoint /open_file_from_iso ### Parameters #### Request Body Parameters - **iso_path** (string) - The absolute ISO path to the file on the ISO. - **rr_path** (string) - The absolute Rock Ridge path to the file on the ISO. - **joliet_path** (string) - The absolute Joliet path to the file on the ISO. - **udf_path** (string) - The absolute UDF path to the file on the ISO. ### Returns A PyCdlibIO object allowing access to the file. ``` -------------------------------- ### ISO Creation Parameters Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Parameters used when creating a new ISO image. ```APIDOC ## ISO Creation Parameters ### Description These parameters are used when creating a new ISO image with PyCdlib. ### Parameters #### Request Body Parameters - **sys_ident** (string) - The system identification string to use on the new ISO. - **vol_ident** (string) - The volume identification string to use on the new ISO. - **set_size** (integer) - The size of the set of ISOs this ISO is a part of. - **seqnum** (integer) - The sequence number of the set of this ISO. - **log_block_size** (integer) - The logical block size to use for the ISO. Defaults to 2048. - **vol_set_ident** (string) - The volume set identification string to use on the new ISO. - **pub_ident_str** (string) - The publisher identification string to use on the new ISO. - **preparer_ident_str** (string) - The preparer identification string to use on the new ISO. - **app_ident_str** (string) - The application identification string to use on the new ISO. - **copyright_file** (string) - The name of a file at the root of the ISO to use as the copyright file. - **abstract_file** (string) - The name of a file at the root of the ISO to use as the abstract file. - **bibli_file** (string) - The name of a file at the root of the ISO to use as the bibliographic file. - **vol_expire_date** (string) - The date that this ISO will expire at. - **app_use** (string) - Arbitrary data that the application can stuff into the primary volume descriptor of this ISO. - **joliet** (integer or boolean) - Controls Joliet levels. 1, 2, or 3 for Joliet levels, None for no Joliet (default). False means no Joliet, True means level 3. - **rock_ridge** (string or None) - Controls Rock Ridge extensions. '1.09', '1.10', or '1.12' to add specified version, None for no Rock Ridge (default). - **xa** (boolean) - Whether to add the ISO9660 Extended Attribute extensions. Defaults to False. - **udf** (string or None) - Controls UDF support. '2.60' for version 2.60, None for no UDF (default). All other values are disallowed. ### Returns Nothing. ``` -------------------------------- ### Initialize PyCdlib Object Source: https://clalancette.github.io/pycdlib/example-creating-new-basic-iso.html Create a new PyCdlib object. This object can be used to either open an existing ISO or create a new one. ```python iso = pycdlib.PyCdlib() ``` -------------------------------- ### Estimate Filesystem Size for wodim Source: https://clalancette.github.io/pycdlib/pycdlib-genisoimage.html Use the -print-size flag to capture the required filesystem size for piping to wodim in Disk At Once mode. ```shell cdblocks=` pycdlib-genisoimage −print−size −quiet ... ` pycdlib-genisoimage ... | wodim ... tsize=${cdblocks}s − ``` -------------------------------- ### Add Directory to ISO Source: https://clalancette.github.io/pycdlib/example-forcing-consistency.html Add a new directory to the ISO image. ```python iso.add_directory('/DIR1') ``` -------------------------------- ### Extract Data from Existing ISO Source: https://clalancette.github.io/pycdlib/example-extracting-data-from-iso.html This snippet demonstrates how to create a new ISO in memory, add a file to it, write the ISO to a BytesIO object, and then extract that file back out. It utilizes BytesIO for in-memory operations, avoiding temporary file writes. ```python try: from cStringIO import StringIO as BytesIO except ImportError: from io import BytesIO import pycdlib iso = pycdlib.PyCdlib() iso.new() foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1') out = BytesIO() iso.write_fp(out) iso.close() iso.open_fp(out) extracted = BytesIO() iso.get_file_from_iso_fp(extracted, iso_path='/FOO.;1') iso.close() print(extracted.getvalue().decode('utf-8')) ``` -------------------------------- ### ISO Navigation and State Commands Source: https://clalancette.github.io/pycdlib/pycdlib-explorer.html Commands for navigating the ISO file structure and managing the current session state. ```APIDOC ## cd ### Description Changes the current working directory within the ISO. ### Parameters - **iso_dir** (string) - Required - Target directory path. ## ls ### Description Lists the contents of the current working directory. ## print_mode [iso9660|rr|joliet|udf] ### Description Sets or displays the current filename mode for printing and operations. ``` -------------------------------- ### PyCdlib Facades Source: https://clalancette.github.io/pycdlib/pycdlib-api.html Provides facade objects for simplified manipulation of specific ISO 9660 extensions. ```APIDOC ## GET /joliet_facade ### Description Returns a facade object for manipulating the Joliet portions of the ISO. ### Method GET ### Endpoint /joliet_facade ### Parameters None. ### Response #### Success Response (200) - **PyCdlibJoliet object** - An object to interact with the Joliet extensions of the ISO. ## GET /rock_ridge_facade ### Description Returns a facade object for manipulating the Rock Ridge portions of the ISO. ### Method GET ### Endpoint /rock_ridge_facade ### Parameters None. ### Response #### Success Response (200) - **PyCdlibRockRidge object** - An object to interact with the Rock Ridge extensions of the ISO. ## GET /udf_facade ### Description Returns a facade object for manipulating the UDF portions of the ISO. ### Method GET ### Endpoint /udf_facade ### Parameters None. ### Response #### Success Response (200) - **PyCdlibUDF object** - An object to interact with the UDF extensions of the ISO. ``` -------------------------------- ### Add Directory with Joliet Path Source: https://clalancette.github.io/pycdlib/example-creating-joliet-iso.html Create a new directory on the ISO. Similar to adding files, the `joliet_path` argument is required for Joliet-enabled directories, specifying its absolute path. ```python iso.add_directory('/DIR1', joliet_path='/dir1') ``` -------------------------------- ### Add a file to the ISO Source: https://clalancette.github.io/pycdlib/example-creating-udf-iso.html Add a file from a byte stream, specifying both the ISO9660 path and the UDF path. ```python foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1', udf_path='/foo') ``` -------------------------------- ### Add File to ISO Source: https://clalancette.github.io/pycdlib/example-forcing-consistency.html Add a new file to the ISO image using `add_fp`, providing the file content as a BytesIO object, its length, and the target path. ```python foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1') ``` -------------------------------- ### Open ISO from Memory Source: https://clalancette.github.io/pycdlib/example-modifying-file-in-place.html Opens an ISO image that has been previously written to a BytesIO object. ```python iso.open_fp(outiso) ``` -------------------------------- ### Write and Close ISO File Source: https://clalancette.github.io/pycdlib/example-creating-hybrid-bootable-iso.html Writes the constructed ISO image to a file named 'eltorito.iso' and then closes the PyCdlib object, releasing any resources. ```python iso.write('eltorito.iso') iso.close() ``` -------------------------------- ### Add File from Memory Source: https://clalancette.github.io/pycdlib/example-creating-rock-ridge-iso.html Add a file to the ISO using a byte string, requiring the rr_name argument for Rock Ridge compatibility. ```python foostr = b'foo\n' iso.add_fp(BytesIO(foostr), len(foostr), '/FOO.;1', rr_name='foo') ``` -------------------------------- ### DVD-Video Compliant UDF Filesystem Generation Source: https://clalancette.github.io/pycdlib/pycdlib-genisoimage.html Generates a DVD-Video compliant UDF filesystem by sorting content and adding padding. Requires a VIDEO_TS directory with all-caps filenames. ```APIDOC ## DVD-Video Compliant UDF Filesystem Generation ### Description Generate a DVD-Video compliant UDF filesystem. This is done by sorting the order of the content of the appropriate files and by adding padding between the files if needed. Note that the sorting only works if the DVD-Video filenames include uppercase characters only. Note that in order to get a DVD-Video compliant filesystem image, you need to prepare a DVD-Video compliant directory tree. This requires a directory **VIDEO_TS** (all caps) in the root directory of the resulting DVD, and usually another directory **AUDIO_TS**. **VIDEO_TS** needs to include all needed files (filenames must be all caps) for a compliant DVD-Video filesystem. ### Method (Not supported by pycdlib-genisoimage) ``` -------------------------------- ### List Find Syntax Source: https://clalancette.github.io/pycdlib/pycdlib-genisoimage.html Lists the available find command syntax. ```APIDOC ## List Find Syntax ### Description Lists the available **find**(1) syntax. ### Method (Not explicitly defined, but implied by option usage) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ``` pycdlib-genisoimage --help-find ``` ### Response N/A ``` -------------------------------- ### Write and close the ISO Source: https://clalancette.github.io/pycdlib/example-creating-udf-iso.html Finalize the ISO image by writing it to disk and closing the object. ```python iso.write('new.iso') iso.close() ``` -------------------------------- ### Write ISO to File Source: https://clalancette.github.io/pycdlib/example-forcing-consistency.html Write the ISO image to a file. The `write` method implicitly performs a metadata update. ```python iso.write('new.iso') ``` -------------------------------- ### Follow Symbolic Links Source: https://clalancette.github.io/pycdlib/pycdlib-genisoimage.html Controls whether symbolic links are followed when generating the filesystem. If not in use, symbolic links are entered using Rock Ridge if enabled, otherwise they are ignored. ```APIDOC ## Follow Symbolic Links ### Description Follow symbolic links when generating the filesystem. When this option is not in use, symbolic links will be entered using Rock Ridge if enabled, otherwise they will be ignored. ### Method (Not supported by pycdlib-genisoimage) ```