Skip to content

Commit 91676db

Browse files
committed
Squashed in FATSTAT.LUA more.
1 parent ae02d29 commit 91676db

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

demo/xtra/FATSTAT.LUA

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ function FD(ts,rs,nf,sf,rd,sc)
1515
local c,r=math.floor((ts-rs-(nf*sf)-rd)/sc)r=c<4085 and 12 or c<65525 and 16 or 32 return r,c end
1616
function CC(fat,sc)
1717
local h,c={},sc
18-
while c>=2 and c<0xFF8 do table.insert(h,c)c=fat[c] end return h
19-
end
18+
while c>=2 and c<0xFF8 do table.insert(h,c)c=fat[c] end return h end
2019
function FR(c)
2120
table.sort(c)local ranges,i={},1
2221
while i<=#c do
@@ -31,14 +30,14 @@ function DE(f,o,e,fat)
3130
if fb~=229 and(en:byte(12)&8)==0 then
3231
local n,x=en:sub(1,8):gsub("+$",""),en:sub(9,11):gsub("+$","")
3332
io.write(string.format("\t%8s %3s %s\n",n,x,FR(CC(fat,R16(en,27)))))end end end
34-
function FC(fat,f,st,s,uc)
33+
function FC(fa,f,st,s,uc)
3534
local fr,z={},string.rep("\0",s)io.write("\n\tFree Space ")
36-
for i=2,uc+1 do if fat[i]==0 then table.insert(fr,i)if Z then local o=st+(i-2)*s f:seek("set",o)f:write(z)end end end print(FR(fr))end
37-
F={}for _,v in ipairs(arg)do if v=="-z" then Z=1 else table.insert(F,v)end end for _,file in ipairs(F)do
38-
local f=io.open(file,(Z and"r+b"or"rb"))if f then
39-
print(file..":")
35+
for i=2,uc+1 do if fa[i]==0 then table.insert(fr,i)if Z then f:seek("set",st+(i-2)*s)f:write(z)end end end print(FR(fr))end
36+
F={}for _,v in ipairs(arg)do if v=="-z" then Z=1 else table.insert(F,v)end end for _,fn in ipairs(F)do
37+
local f=io.open(fn,(Z and"r+b"or"rb"))if f then
38+
print(fn..":")
4039
local b,o=f:read(512)o=b:sub(1,1):byte()if o==235 or o==233 then
41-
local bs,sc,rs,nf,re,ts,sf=R16(b,12),b:byte(14),R16(b,15),b:byte(17),R16(b,18),R16(b,20),R16(b,23) if ts==0 then ts=R32(b,32) end
40+
local bs,sc,rs,nf,re,ts,sf=R16(b,12),b:byte(14),R16(b,15),b:byte(17),R16(b,18),R16(b,20),R16(b,23)if ts==0 then ts=R32(b,32)end
4241
local rd,fo,fs,ro,ft,uc=math.ceil(re*32/bs),rs*bs,sf*bs,(rs+nf*sf)*bs ft,uc=FD(ts,rs,nf,sf,rd,sc)
4342
print(string.format("\t FAT type: FAT%s\n\t Bytes/sector: %d\n\tSectors/cluster: %d\n\n",ft,bs,sc))
4443
local fat=ft==12 and F12(f,fo,fs)or ft==16 and F16(f,fo,fs)or error("Non-FAT type")

0 commit comments

Comments
 (0)