Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!news.cs.indiana.edu!maytag!watstat.waterloo.edu!dmurdoch From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Newsgroups: comp.os.msdos.programmer Subject: Re: Can I read a subdirectory file ? Message-ID: <1990Dec31.044803.27739@maytag.waterloo.edu> Date: 31 Dec 90 04:48:03 GMT References: <14237@june.cs.washington.edu> <1990Dec28.174004.12184@cbnewsc.att.com> <1990Dec29.152859.25732@maytag.waterloo.edu> <1990Dec29.195859.28295@uwasa.fi> Sender: daemon@maytag.waterloo.edu (Admin) Organization: University of Waterloo Lines: 26 In article <1990Dec29.195859.28295@uwasa.fi> ts@uwasa.fi (Timo Salmi) writes: > >I don't quite understand this. Why can't one change the >subdirectory file attribute temporarily not to be directory, do >one's reading and change it back. Or to be on the safe side, copy >the file, change back and then browse the copied file. Turbo Pascal >at least should have the facilities to do this. I have to admit, >though, that this is partly guesswork on my part, since I have not >tried out exactly this procedure, but only something similar for a >slightly different purpose. (Of course it would be relatively easy >to test whether this is so, or not.) There are two problems: First, the legal DOS calls don't let you touch the Subdirectory bit in the attributes byte. I don't know if undocumented ones would let you, but tend to doubt it: you probably just have to go in at the sector level to make the change. The second problem is that a directory entry for a subdirectory always has the length field set to 0. The only way to know how long the directory is is to trace through it until you get to an unused entry, or the end of the chain of clusters that make it up. I've never understood the reason for this, but it means that if you just turn off the Subdirectory bit, you'll end up with a zero length file and won't be able to read it. Duncan Murdoch