1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-06-02 10:41:35 +00:00

More consistent API for sdFAT library

This commit is contained in:
David Schmenk 2017-12-15 11:40:04 -08:00
parent 35da78ce92
commit 2bfcfe87bf
6 changed files with 44 additions and 44 deletions

View File

@ -17,29 +17,29 @@ import sdFAT
//
// Interface
//
struc t_fatio
word dirGet
word dirSet
word dirNew
word dirRemove
word fileRename
word fileRemove
word fileExists
word fileOpenFirst
word fileOpenNext
word fileOpen
word fileClose
word fileRead
word fileWrite
word fileSync
word fileRewind
word fileSeek
word fileSeekOffset
word filePos
word fileSize
word fileTruncate
word fileIsDir
word fileIsFile
end
word sdFAT // sdFAT interface
end
struc t_fatio
word getDir
word setDir
word newDir
word removeDir
word renameFile
word removeFile
word existsFile
word openFirstFile
word openNextFile
word openFile
word closeFile
word readFile
word writeFile
word syncFile
word rewindFile
word seekFile
word seekOffsetFile
word posFile
word sizeOfFile
word truncateFile
word isDir
word isFile
end
word sdFAT // sdFAT interface
end

View File

@ -9,19 +9,19 @@ byte[64] pathname
def fatCat(path)#0
byte filename[32]
sdFAT:dirSet(path)
sdFAT:setDir(path)
puts("Directory of "); puts(path); puts(":\n")
sdFAT:fileOpenFirst(@filename)
sdFAT:openFirstFile(@filename)
while filename
puts(" "); puts(@filename)
if sdFAT:fileIsDir(); putc('/'); fin
if sdFAT:isDir(); putc('/'); fin
putln
sdFAT:fileClose()
sdFAT:fileOpenNext(@filename)
sdFAT:closeFile()
sdFAT:openNextFile(@filename)
loop
end
sdFAT:dirGet(@cwd)
sdFAT:getDir(@cwd)
if cwd[cwd] <> '/' // append '/' to cwd if needed
cwd++
cwd[cwd] = '/'

View File

@ -95,7 +95,7 @@ def bigFatRead(buf, len)
else
fatLen = len
fin
fatLen = sdFAT:fileRead(buf, fatLen)
fatLen = sdFAT:readFile(buf, fatLen)
if fatLen > 0
xferLen = xferLen + fatLen
len = len - fatLen
@ -145,7 +145,7 @@ def fatCopyFrom(src, dst, type, aux)
//
// Copy FAT file over in big chunks
//
if sdFAT:fileOpen(src, O_READ)
if sdFAT:openFile(src, O_READ)
repeat
copyLen = bigFatRead(copyBuf, COPY_BUF_SIZE)
if copyLen
@ -156,7 +156,7 @@ def fatCopyFrom(src, dst, type, aux)
fin
fin
until copyLen == 0
sdFAT:fileClose()
sdFAT:closeFile()
else
puts("Error opening FAT file:"); puts(src); putln
fin

View File

@ -91,7 +91,7 @@ def bigFatWrite(buf, len)
else
fatLen = len
fin
fatLen = sdFAT:fileWrite(buf, fatLen)
fatLen = sdFAT:writeFile(buf, fatLen)
if fatLen > 0
xferLen = xferLen + fatLen
len = len - fatLen
@ -121,7 +121,7 @@ def fatCopyTo(src, dst)
//
// Copy file over in big chunks
//
if sdFAT:fileOpen(dst, O_READ | O_WRITE | O_CREAT)
if sdFAT:openFile(dst, O_READ | O_WRITE | O_CREAT)
repeat
copyLen = fileio:read(ref, copyBuf, COPY_BUF_SIZE)
if copyLen
@ -130,7 +130,7 @@ def fatCopyTo(src, dst)
fin
fin
until copyLen == 0
sdFAT:fileClose()
sdFAT:closeFile()
else
puts("Error opening FAT file:"); puts(dst); putln
fin

View File

@ -64,7 +64,7 @@ def bigFatWrite(buf, len)
else
fatLen = len
fin
fatLen = sdFAT:fileWrite(buf, fatLen)
fatLen = sdFAT:writeFile(buf, fatLen)
if fatLen > 0
xferLen = xferLen + fatLen
len = len - fatLen
@ -93,7 +93,7 @@ def fatReadImage(src, drv, order)
//
// Copy FAT image over one track at a time
//
if sdFAT:fileOpen(src, O_READ | O_WRITE | O_CREAT)
if sdFAT:openFile(src, O_READ | O_WRITE | O_CREAT)
if !drv; putc(7); fin
for blocknum = 0 to 279 step COPY_BLK_SIZE
if drv
@ -120,7 +120,7 @@ def fatReadImage(src, drv, order)
next
if !drv; putc(7);fin
putln
sdFAT:fileClose()
sdFAT:closeFile()
else
puts("Error opening image file:"); puts(src); putln
return -1

View File

@ -65,7 +65,7 @@ def bigFatRead(buf, len)
else
fatLen = len
fin
fatLen = sdFAT:fileRead(buf, fatLen)
fatLen = sdFAT:readFile(buf, fatLen)
if fatLen > 0
xferLen = xferLen + fatLen
len = len - fatLen
@ -94,7 +94,7 @@ def fatWriteImage(src, drv, order)
//
// Copy FAT image over one track at a time
//
if sdFAT:fileOpen(src, O_READ)
if sdFAT:openFile(src, O_READ)
if !drv; putc(7); fin
for blocknum = 0 to 279 step COPY_BLK_SIZE
copyLen = bigFatRead(inBuf, COPY_BUF_SIZE)
@ -122,7 +122,7 @@ def fatWriteImage(src, drv, order)
next
if !drv; putc(7);fin
putln
sdFAT:fileClose()
sdFAT:closeFile()
else
puts("Error opening image file:"); puts(src); putln
return -1