mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 06:54:04 +09:00
device files are mounted under the drive letter of dollarsign
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
let f = files.open("CON")
|
||||
let f = files.open("$:/CON")
|
||||
f.swrite("Hello, world! I'm just writing to a file named 'CON'\n")
|
||||
f.close()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
let fout = files.open("FBIPF")
|
||||
let fout = files.open("$:/FBIPF")
|
||||
let fin = files.open(_G.shell.resolvePathInput(exec_args[1]).full)
|
||||
|
||||
let ipfRead = fin.bread()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
let f = files.open("RND")
|
||||
let f = files.open("$:/RND")
|
||||
let mlen = 512
|
||||
let m = sys.malloc(mlen)
|
||||
|
||||
|
||||
@@ -94,15 +94,17 @@ _TVDOS.DRV.FS = {}
|
||||
class TVDOSFileDescriptor {
|
||||
|
||||
constructor(path0, driverID) {
|
||||
if (driverID === undefined) {
|
||||
if (!files.reservedNames.includes(path0)) {
|
||||
throw Error(`${path0} is not a valid device file`)
|
||||
if (path0.startsWith("$")) {
|
||||
let devName = path0.substring(3)
|
||||
|
||||
if (!files.reservedNames.includes(devName)) {
|
||||
throw Error(`${devName} is not a valid device file`)
|
||||
}
|
||||
|
||||
this._driveLetter = undefined
|
||||
this._path = path0
|
||||
this._driverID = `DEV${path0}`
|
||||
this._driver = _TVDOS.DRV.FS[`DEV${path0}`] // can't just put `driverID` here
|
||||
this._driverID = `DEV${devName}`
|
||||
this._driver = _TVDOS.DRV.FS[`DEV${devName}`] // can't just put `driverID` here
|
||||
}
|
||||
else {
|
||||
let p = path0.replaceAll("/", "\\")
|
||||
@@ -111,7 +113,7 @@ class TVDOSFileDescriptor {
|
||||
p = p.substring(0, p.length - 1)
|
||||
}
|
||||
this._driveLetter = p[0]
|
||||
this._path = p.substring(2) // detaches A:
|
||||
this._path = p.substring(2) // detaches $:
|
||||
this._driverID = driverID
|
||||
this._driver = _TVDOS.DRV.FS[driverID]
|
||||
serial.println(`TVDOSFileDescriptor input path: ${path0}, p = ${p}, driveLetter = ${this._driveLetter}, path = ${this._path}`)
|
||||
@@ -810,6 +812,12 @@ files.open = (fullPath) => {
|
||||
if (fullPath[2] != '/' && fullPath[2] != '\\') throw Error("Expected full path with drive letter, got " + fullPath)
|
||||
let driveLetter = fullPath[0].toUpperCase()
|
||||
let driver = _TVDOS.DRIVEFS[driveLetter]
|
||||
|
||||
// special device files ($:\NUL, $:\CON, etc)
|
||||
if ("$" == driveLetter) {
|
||||
return new TVDOSFileDescriptor(fullPath.toUpperCase())
|
||||
}
|
||||
|
||||
return new TVDOSFileDescriptor(fullPath, driver)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ if (!magicMatching) {
|
||||
}
|
||||
|
||||
// decode input image
|
||||
let ipfFile = files.open("FBIPF")
|
||||
let ipfFile = files.open("$:/FBIPF")
|
||||
graphics.clearText(); graphics.clearPixels(0); graphics.clearPixels2(0)
|
||||
ipfFile.pwrite(infilePtr, infile.size, 0)
|
||||
sys.free(infilePtr)
|
||||
|
||||
Reference in New Issue
Block a user