/*
File: BuildISO.c
Description:Try to build a ISO 9660 floppy disc, interactively.
Currently only builds the Primary Volume Descriptor
and puts files at the root level. Does not do
subdirectories.
Author: BB
Copyright: Copyright: � 1988-1999 by Apple Computer, Inc.
all rights reserved.
Disclaimer: You may incorporate this sample code into your applications without
restriction, though the sample code has been provided "AS IS" and the
responsibility for its operation is 100% yours. However, what you are
not permitted to do is to redistribute the source as "DSC Sample Code"
after having made changes. If you're going to re-distribute the source,
we require that you make it clear in the source that the code was
descended from Apple Sample Code, but that you've made changes.
Change History (most recent first):
6/24/99 Updated for Metrowerks Codewarror Pro 2.1(KG)
1/94 Converted to Universal Headers. Fixed a bug which prevented
Apple extensions from working correctly.
5/90 Modified for d e v e l o p and Think C 4.0
7/1/88 Original Version for the Macintosh(BB)
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <Files.h>
#include <OSUtils.h>
#include <Memory.h>
#include <Errors.h>
#include <strings.h>
#include <Devices.h>
#include <MacMemory.h>
#include "HighSierra.h"
#include "BuildISO.h"
#define FLOPPY_SIZE 0x186 /* size in 2k blocks of a 800k floppy */
#include "ErrorMsg.h"
#include "i_o.h"
#include "Support.h"
#include "MyDialog.h"
Str255 nullStr = "\p";
Str255 rootName = "\p\000";
Str255 parentName = "\p\001";
/************************************************************************
*
* Function: CreatePVD
*
* Purpose: create the contents of the Primary Volume Descriptor.
*
* Returns: void
*
* Side Effects: adds to the output file.
*
* Description: go through all the primary volume descriptor, showing
* each field in all it's glory. We don't bother showing
* the extra blanks at the end of each string field.
*
*
************************************************************************/
OSErr
CreatePVD(short referenceNumber)
{
PVD p;
OSErr result;
long offset;
char volID[33];
Boolean goOn;
ClearOut((char *)&p, sizeof(p));
p.VDType = 1;
p.VSStdId[0] = 'C';
p.VSStdId[1] = 'D';
p.VSStdId[2] = '0';
p.VSStdId[3] = '0';
p.VSStdId[4] = '1';
p.VSStdVersion = 1;
CharCopy(p.systemIdentifier, "Apple Computer, Inc., Type:0001", sizeof(p.systemIdentifier));
goOn = AskForString((char *)"\pWhat do you want to call this volume? (32 characters or less)", volID);
if (goOn == false)
return -1;
NormalizeVolumeName(volID);
CharCopy(p.volumeIdentifier, volID, sizeof(p.volumeIdentifier));
p.lsbVolumeSpaceSize = NormalizeLong((long)FLOPPY_SIZE);
p.msbVolumeSpaceSize = (long)FLOPPY_SIZE;
p.lsbVolumeSetSize = NormalizeWord(FLOPPY_SIZE);
p.msbVolumeSetSize = FLOPPY_SIZE;
p.lsbVolumeSetSequenceNumber = NormalizeWord(1);
p.msbVolumeSetSequenceNumber = 1;
p.lsbLogicalBlockSize = NormalizeWord(CDBLKSIZE);
p.msbLogicalBlockSize = CDBLKSIZE;
p.lsbPathTableSize = NormalizeLong(PATHTBLSIZE);
p.msbPathTableSize = PATHTBLSIZE;
p.lsbPathTable1 = NormalizeLong(LSBPATH);
p.msbPathTable1 = MSBPATH;
p.lsbPathTable2 = 0L;
p.msbPathTable2 = 0L;
/* Exercise for reader: get the time via GetTime() and convert
** to string of the format shown below for these strange dates.
** Use that date and time to fill the various volume date fields.
** The date shown is my daughter's birth date and time...
*/
CharCopy(p.volumeCreation, "19870914060100000", sizeof(p.volumeCreation));
CharCopy(p.volumeModification, "19870914060100000", sizeof(p.volumeModification));
CharCopy(p.volumeExpiration, "00000000000000000", sizeof(p.volumeExpiration));
CharCopy(p.volumeEffective, "19870914060100000", sizeof(p.volumeEffective));
p.FileStructureStandardVersion = 1;
SpaceOut(p.volumeSetIdentifier, sizeof(p.volumeSetIdentifier));
SpaceOut(p.publisherIdentifier, sizeof(p.publisherIdentifier));
SpaceOut(p.dataPreparerIdentifier, sizeof(p.dataPreparerIdentifier));
SpaceOut(p.applicationIdentifier, sizeof(p.applicationIdentifier));
SpaceOut(p.copyrightFileIdentifier, sizeof(p.copyrightFileIdentifier));
SpaceOut(p.abstractFileIdentifier, sizeof(p.abstractFileIdentifier));
SpaceOut(p.bibliographicFileIdentifier, sizeof(p.bibliographicFileIdentifier));
CreateDirRcd((DirRcd *)&p.rootDirectoryRecord, rootName,
DIRECTORY, CDBLKSIZE, (short) directoryBit, 0L, 0L, 0);
p.Reserved1 = 0;
ClearOut(p.Reserved2, sizeof(p.Reserved2));
ClearOut(p.Reserved3, sizeof(p.Reserved3));
p.Reserved4 = 0;
#ifdef VERBOSE /* if I want to verify what I've done */
DumpPVD(&p);
#endif
offset = (long) HSVOLSTART * (long) CDBLKSIZE;
result = isoWrite(referenceNumber, (Ptr)&p, (long) sizeof(p), (long)offset);
if (result != noErr)
ErrorMsg("CreatePVD: isoWrite() returned %d", result);
else
ErrorMsg("volume descriptors successfully created.");
return result;
}
/************************************************************************
*
* Function: CreateVDT
*
* Purpose: create the contents of the Volume Descriptor Terminator
*
* Returns: void
*
* Side Effects: adds to the output file.
*
* Description: Build a simple VDT, fill it in, and write it out to
* a famous place.
*
*
************************************************************************/
OSErr
CreateVDT(short referenceNumber)
{
PVD p;
OSErr result;
long offset;
ClearOut((char *)&p, sizeof(p));
p.VDType = 255;
p.VSStdId[0] = 'C';
p.VSStdId[1] = 'D';
p.VSStdId[2] = '0';
p.VSStdId[3] = '0';
p.VSStdId[4] = '1';
p.VSStdVersion = 1;
offset = (long) HSTERMSTART * (long) CDBLKSIZE;
result = isoWrite(referenceNumber, (Ptr)&p, (long) sizeof(p), (long)offset);
if (result != noErr)
ErrorMsg("CreateVDT: isoWrite() returned %d", result);
return result;
}
/************************************************************************
*
* Function: CreatePathTable
*
* Purpose: create path tables
*
* Returns: nothing
*
* Side Effects: writes lsb path table and msb path table
*
* Description: We'll assume just the root. Dump out the path
* path table in both formats. We'll put the
* path table in famous spots.
*
************************************************************************/
OSErr
CreatePathTable(short referenceNumber)
{
char buffer[CDBLKSIZE];
PathTableRecordPtr d;
long offset;
OSErr result;
ClearOut(buffer, sizeof(buffer));
d = (PathTableRecordPtr) &buffer[0];
d->len_di = 1;
d->XARlength = 0;
d->dirLocation = NormalizeLong(DIRECTORY);
d->parentDN = 0;
offset = LSBPATH * (long) CDBLKSIZE;
result = isoWrite(referenceNumber, buffer, (long) CDBLKSIZE, offset);
if (result != noErr)
ErrorMsg("CreatePathTable: isoWrite() returned %d", result);
d->len_di = 1;
d->dirLocation = DIRECTORY;
d->parentDN = 0;
offset = MSBPATH * (long) CDBLKSIZE;
result = isoWrite(referenceNumber, buffer, (long) CDBLKSIZE, offset);
if (result != noErr)
ErrorMsg("CreatePathTable: isoWrite() returned %d", result);
return result;
}
/************************************************************************
*
* Function: CreateDirRcd
*
* Purpose: Create a directory record for a file
*
* Returns: none
*
* Side Effects: fills *d with directory information. We assume
* caller has allocated space for d.
*
* Description:
*
************************************************************************/
void
CreateDirRcd(DirRcd *d, StringPtr name, long start, long length, short flags, OSType fType, OSType fCreator, short finderFlags)
{
Ptr dPtr;
DateTimeRec today;
d->XARlength = 0;
d->lsbStart = NormalizeLong(start);
d->msbStart = start;
d->lsbDataLength = NormalizeLong(length);
d->msbDataLength = length;
d->fileFlags = flags;
if (finderFlags & fInvisible)
d->fileFlags |= exis
iso9660.zip_ISO 9660 _ISO 文件_iso9660
版权申诉
72 浏览量
2022-09-22
18:53:57
上传
评论
收藏 57KB ZIP 举报
![avatar](https://profile-avatar.csdnimg.cn/dc78d2406d17417ca42db3bd43b9c72a_weixin_42652674.jpg!1)
御道御小黑
- 粉丝: 62
- 资源: 1万+
最新资源
- 机器学习客观题测验,备战期末复习的题库
- HBR740语音识别协处理芯片开发工具包(硬件参考设计原理图+PCB+51单片机软件驱动源码DEMO例程+文档资料).zip
- 数据库管理工具:dbeaver-ce-23.0.1-macos-aarch64.dmg
- M25P20, M25P40, M25P80, M25P16, M25P32, M25P64存储 SPI FLASH C语言驱动
- Matlab基于PCA算法的简单图像人脸识别.zip
- 免费的画图工具drawio,可以代替visio,版本24.5.3,适用于windows
- 瑞昱RTL8723DS-WiFi-linux- android 驱动 内含详细移植说明,支持android4.4
- AMSR/ADEOS-II L1A Raw Observation Counts, Version 3用户手册
- zaopingshujufenxi.zip
- 六级作文模板万能句型pdf.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)