文件格式解析:ISO9660 (ISO文件) -- Python

  while True:
    file.seek(block)

    buffer = file.read(ISO9660_BLKSZ)
    if len(buffer) < ISO9660_BLKSZ:
      break

    if buffer[1:6] == "CD001":
      type = ord(buffer[0])

      print("Volume Offset: %08x" % block)
      print("Volume Version: %02x" % ord(buffer[6]))
      print("Standard ID: %s" % buffer[1:6])

      if type == ISO9660_VOLDESC_BOOT:
        print("Volume Type: ISO9660(%02x) Boot Record" % type)
        print("Boot System Identifier: %s" % buffer[7:39])
        print("Boot Identifier: %s" % buffer[40:71])
        print

      elif type == ISO9660_VOLDESC_PRIMARY or type == ISO9660_VOLDESC_SUPP:
        if type == ISO9660_VOLDESC_PRIMARY:
          print("Volume Type: ISO9660(%02x) Primary Volume Descriptor" % type)
        else:
          print("Volume Type: ISO9660(%02x) Supplementary Volume Descriptor" % type)
        print("System ID: %s" % buffer[8:39])
        print("Volume ID: %s" % buffer[39:71])

        print("Volume Space Size: %d" % struct.unpack("<L", buffer[80:84]))
        print("Volume Set Size: %d" % struct.unpack("<H", buffer[120:122]))
        print("Volume Sequence Number: %d" % struct.unpack("<H", buffer[124:126]))
        print("Logical Block Size: %d" % struct.unpack("<H", buffer[128:130]))

        print("Path Table Size: %d" % struct.unpack("<L", buffer[132:136]))
        print("Location of Occurrence of Type L Path Table: %d" % struct.unpack("<L", buffer[140:144]))
        print("Location of Optional Occurrence of Type L Path Table: %d" % struct.unpack("<L", buffer[144:148]))
        print("Location of Occurrence of Type M Path Table: %d" % struct.unpack(">L", buffer[148:152]))
        print("Location of Optional Occurrence of Type L Path Table: %d" % struct.unpack(">L", buffer[152:156]))        
        
        # 156 - 190
        print("FDD - LEN-DR: %d" % struct.unpack("<b", buffer[156:157]))
        print("FDD - Extended Attribute Record Length: %d" % struct.unpack("<b", buffer[157:158]))
        print("FDD - Location of Extent: %d" % struct.unpack("<L", buffer[158:162]))
        print("FDD - Data Length: %d" % struct.unpack("<L", buffer[166:170]))
        print("FDD - Recording Date and Time: %d-%d-%d %d:%d:%d" % (ord(buffer[174]) + 1900,ord(buffer[175]),ord(buffer[176]),ord(buffer[177]),ord(buffer[178]),ord(buffer[179])))
        print("FDD - File Flags: %d" % ord(buffer[181]))
        print("FDD - File Unit Size: %d" % ord(buffer[182]))
        print("FDD - Interleave Gap Size: %d" % ord(buffer[183]))
        print("FDD - Volume Sequence Number: %d" % struct.unpack("<H", buffer[184:186]))
        x = ord(buffer[188])
        print("FDD - Length of File Identifier: %d" % x)
        print("FDD - File Identifier: %s" % buffer[189:188 + x])
        print("FDD - Padding Field:")
        print("FDD - System Use:")
        
        print("Volume Set ID: %s" % buffer[190:318].strip())
        print("Publisher ID: %s" % buffer[318:446].strip())
        print("Data Preparer ID: %s" % buffer[446:574].strip())
        print("Application ID: %s" % buffer[574:702].strip())
        print("Copyright File ID: %s" % buffer[702:739].strip())
        print("Abstract File ID: %s" % buffer[739:776].strip())
        print("Bibliographic File ID: %s" % buffer[776:813].strip())
      elif type == ISO9660_VOLDESC_PART:
        print("Volume Type: ISO9660(%02x) Volume Partition Descriptor" % type)
        print

      elif type == ISO9660_VOLDESC_END:
        print("Volume Type: ISO9660(%02x) Volume Descriptor Set Terminator" % type)
        print
        break

      else:
        print("Volume Type: ISO9660(%02x) Reserved Volume Descriptor" % type)
        print

    block = block + 0x800

  file.close()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ISO-8601时间格式是一种广泛使用的日期和时间表示方法,它的格式为yyyy-MM-dd'T'HH:mm:ssZZ。要进行ISO-8601时间格式的转换,可以使用不同编程语言的内置函数或库来实现。 在Python中,可以使用datetime模块来进行ISO-8601时间格式的转换。可以使用datetime.strptime()函数将字符串解析为datetime对象,然后使用datetime.strftime()函数将datetime对象格式化为所需的字符串格式。例如,要将ISO-8601时间格式的字符串转换为本地时区的时间,可以使用以下代码: ```python import datetime iso_datetime = "2021-10-26T14:53:29+08:00" dt = datetime.datetime.strptime(iso_datetime, "%Y-%m-%dT%H:%M:%S%z") local_dt = dt.astimezone(datetime.timezone(datetime.timedelta(hours=8))) local_datetime_str = local_dt.strftime("%Y-%m-%d %H:%M:%S") print(local_datetime_str) ``` 在Java中,可以使用SimpleDateFormat类来进行ISO-8601时间格式的转换。可以使用SimpleDateFormat.parse()方法将字符串解析为Date对象,然后使用SimpleDateFormat.format()方法将Date对象格式化为所需的字符串格式。例如,要将ISO-8601时间格式的字符串转换为本地时区的时间,可以使用以下代码: ```java import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static void main(String[] args) throws Exception { String isoDatetime = "2021-10-26T14:53:29+08:00"; SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); Date date = isoFormat.parse(isoDatetime); SimpleDateFormat localFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); localFormat.setTimeZone(TimeZone.getDefault()); String localDatetimeStr = localFormat.format(date); System.out.println(localDatetimeStr); } } ``` 以上代码中,将ISO-8601时间格式的字符串解析为Date对象后,使用SimpleDateFormat将其格式化为本地时区的时间字符串。 请注意,根据不同的编程语言和库的实现,可能需要进行一些调整和配置,以确保正确的ISO-8601时间格式转换。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [python pandas ISO-8601时间转换为本地时间](https://blog.csdn.net/weixin_43924621/article/details/113920166)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [ISO8601时间格式的转换](https://blog.csdn.net/gdvfs12/article/details/120973705)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值