Add id to directory entries
This commit is contained in:
parent
18c5554211
commit
9ff9642f65
@ -41,6 +41,7 @@ export interface IAttributes {
|
||||
|
||||
export interface IStandardDirEntry {
|
||||
type: 'standard-entry'
|
||||
id: string
|
||||
name: string
|
||||
basename: string
|
||||
extension: string
|
||||
@ -53,14 +54,17 @@ export interface IStandardDirEntry {
|
||||
|
||||
export interface ILongFileNameDirEntry {
|
||||
type: 'long-filename-entry'
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface IFinalDirEntry {
|
||||
type: 'final-entry'
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface IUnusedDirEntry {
|
||||
type: 'unused-entry'
|
||||
id: string
|
||||
}
|
||||
|
||||
export type TDirEntry = IStandardDirEntry | ILongFileNameDirEntry | IFinalDirEntry | IUnusedDirEntry
|
||||
@ -304,13 +308,14 @@ function decodeDirectoryEntry(data: DataView, fd: FloppyDisk): TDirEntry | null
|
||||
|
||||
const firstByte = data.getUint8(0)
|
||||
const attributeByte = data.getUint8(11)
|
||||
const id = crypto.randomUUID()
|
||||
|
||||
if (firstByte === 0) {
|
||||
return { type: 'final-entry' }
|
||||
return { type: 'final-entry', id }
|
||||
} else if (firstByte === 0xe5) {
|
||||
return { type: 'unused-entry' }
|
||||
return { type: 'unused-entry', id }
|
||||
} else if (attributeByte === 0x0f) {
|
||||
return { type: 'long-filename-entry' }
|
||||
return { type: 'long-filename-entry', id }
|
||||
} else {
|
||||
const asciiDecoder = new TextDecoder('ascii')
|
||||
const basename = asciiDecoder
|
||||
@ -338,6 +343,7 @@ function decodeDirectoryEntry(data: DataView, fd: FloppyDisk): TDirEntry | null
|
||||
|
||||
const entry: IStandardDirEntry = {
|
||||
type: 'standard-entry',
|
||||
id,
|
||||
name,
|
||||
basename,
|
||||
extension,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user