Heya.

 BBS: Inland Empire Archive
Date: 01-16-93 (15:41)             Number: 379
From: CORIDON HENSHAW              Refer#: NONE
  To: MARK REJHON                   Recvd: NO  
Subj: Heya.                          Conf: (2) Quik_Bas
Hello Mark!

In a msg of <14 Jan 93>, Mark Rejhon writes to All:

 MR> I heard that there is a way to trick DOS to open a directory as a
 MR> file. [deleted] Do[es] anybody here have information on this?

Yes, I do.  You can fool DOS if you use the change attribs
function to remove the DIR attribute, open the directory as
a file, and when you've finished using it, change the
attributes back.  Some example code:

===Chop===
DEFINT A-Z
CONST Nul = -2
CONST True = -1
CONST False = 0
TYPE FileAttrsType
 ReadOnly                AS STRING * 1
 Hidden                  AS STRING * 1
 System                  AS STRING * 1
 VolumeLabel             AS STRING * 1
 Directory               AS STRING * 1
 Archive                 AS STRING * 1
END TYPE
'$INCLUDE: 'qbx.bi'

DIM FileAttrs   AS FileAttrsType

MKDIR "example" 'Make example directory

GetFileAttrs "example", FileAttrs 'Get file attributes
FileAttrs.Directory="0"           'Remove directory attribute
SetFileAttrs "example", FileAttrs 'Set attributes

OPEN "example" FOR BINARY AS #1   'Directory is opened
PRINT "Directory length: "; LOF(1)
CLOSE                             'Close directory

FileAttrs.Directory="1"           'Reset directory attribute
SetFileAttrs "example", FileAttrs 'Set attributes

SUB GetFileAttrs (File$, FileAttrs AS FileAttrsType)
DIM Regs AS RegTypeX

Regs.AX = &H4300
Regs.DS = SSEG(File$)
Regs.DX = SADD(File$)

CALL InterruptX(&H21, Regs, Regs)

IF Regs.CX AND 2 ^ 0 THEN FileAttrs.ReadOnly = "1"
IF Regs.CX AND 2 ^ 1 THEN FileAttrs.Hidden = "1"
IF Regs.CX AND 2 ^ 2 THEN FileAttrs.System = "1"
IF Regs.CX AND 2 ^ 3 THEN FileAttrs.VolumeLabel = "1"
IF Regs.CX AND 2 ^ 4 THEN FileAttrs.Directory = "1"
IF Regs.CX AND 2 ^ 5 THEN FileAttrs.Archive = "1"

END SUB

SUB SetFileAttrs (File$, FileAttrs AS FileAttrsType)
DIM Regs AS RegTypeX

IF FileAttrs.ReadOnly = "1" THEN Regs.CX = Regs.CX + 2 ^ 0
IF FileAttrs.Hidden = "1" THEN Regs.CX = Regs.CX + 2 ^ 1
IF FileAttrs.System = "1" THEN Regs.CX = Regs.CX + 2 ^ 2
IF FileAttrs.VolumeLabel = "1" THEN Regs.CX = Regs.CX + 2 ^ 3
IF FileAttrs.Directory = "1" THEN Regs.CX = Regs.CX + 2 ^ 4
IF FileAttrs.Archive = "1" THEN Regs.CX = Regs.CX + 2 ^ 5

Regs.AX = &H4301
Regs.DS = SSEG(File$)
Regs.DX = SADD(File$)

CALL InterruptX(&H21, Regs, Regs)

END SUB
===Chop===

There you go.

\  Coridon Henshaw  \          ³
  \  Sirrus Software  \      \ ³ /
    \   Sysop,          \  ÄÄÄÄ*ÄÄÄÄ
      \  TCS Concordia    \  / ³ \
        \  34:3416/18       \  ³

...Be there or be hexagonal!

--- GEcho 1.00
 * Origin: Somewhere in the Streeling Sector of Trantor... (1:250/820)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET