flat assembler
Message board for the users of flat assembler.

Index > DOS > Find Directories

Author
Thread Post new topic Reply to topic
rain_storm



Joined: 05 Apr 2007
Posts: 67
Location: Ireland
rain_storm 05 Apr 2007, 18:28
I'm teaching myself file access and have the ability to find and list all files in a specified directory but I cant find and list sub directories they dont seem to be visible to the find first /next interrupts I am using the wildcard "*" not "*.*" so added extensions are not the problem how can I search for (sub) directories instead of files.
Post 05 Apr 2007, 18:28
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 05 Apr 2007, 19:19
Quote:
but I cant find and list sub directories they dont seem to be visible


Post code please Idea

I guess you have wrong attribute mask Wink

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 05 Apr 2007, 19:19
View user's profile Send private message Reply with quote
rain_storm



Joined: 05 Apr 2007
Posts: 67
Location: Ireland
rain_storm 05 Apr 2007, 19:34
You're right attributes set to zero and it lists them thanks it doesnt list them in the debugger I use instead only when I run the exe wtf. Does anyone know which offset of the dta can be used to find out if I'm dealing with a folder I am trying to make a process that will allow users to navigate directories and select a file from the list I wish to list all sub directories together
Post 05 Apr 2007, 19:34
View user's profile Send private message Reply with quote
rain_storm



Joined: 05 Apr 2007
Posts: 67
Location: Ireland
rain_storm 05 Apr 2007, 23:22
I got it through trial n error 10h is the right attribute mask for searching for directories thanks for the pointer NTOSKRNL_VXE this had me stumped for awhile now I hate being an asm novice
Post 05 Apr 2007, 23:22
View user's profile Send private message Reply with quote
rain_storm



Joined: 05 Apr 2007
Posts: 67
Location: Ireland
rain_storm 06 Apr 2007, 01:48
Here is the routine that lists the subdirectories without listing any files. And it seems to run okay on my pc the next thing on the list is to build up a navigation routine and incorporate files in the list thank god it was only a minor setback Very Happy
Code:
org  100h               ; com file
push 0B800h             ; screen text buffer offset
pop  es                 ; for much faster text
mov  al,03h             ; text mode
int  10h                ; do it
mov  ah,01h             ; set cursor attributes
mov  cx,2B20h           ; hide blinking cursor
int  10h                ; do it
mov  ah,1Ah             ; set dta
mov  dx,dta             ; new address
int  21h                ; do it
find:                   ; start of find file routine
    mov  ax,4E00h       ; find first file (and set al to zero)
    mov  dx,wildcard    ; macth name with asciz string
    mov  cx,10h         ; find sub directories.
    int  21h            ; do it
    or   al,al          ; fast error check
    jnz  done           ; if error, we're done
    xor  di,di          ; reset di to top left of screen
prnt:                   ; set up for printing
    mov  cx,0Ch         ; 12 charictors
    mov  si,dta+30      ; from dta (plus filename offset)
    mov  ah,0Fh         ; in black & white
text:                   ; display all charictors on screen
    lodsb               ; get charictor
    stosw               ; write charictor in black & white
    loop text           ; get more charictors
    add  di,88h         ; move to start of new line
    mov  ax,4F00h       ; find next file (and set al to zero)
    int  21h            ; do it (cx = 0 doesnt seem to matter)
    or   al,al          ; fast error check
    jz   prnt           ; print this name too
done:                   ; we are finished searching
    xor ah,ah           ; wait for key press
    int 16h             ; do it
    ret                 ; get outta here
wildcard db "C:\*",0    ; file name (note that theres no extension)
dta      db 128 dup (0) ; dta output buffer
    
Post 06 Apr 2007, 01:48
View user's profile Send private message Reply with quote
rain_storm



Joined: 05 Apr 2007
Posts: 67
Location: Ireland
rain_storm 24 Apr 2007, 16:00
Can anyone tell me what it means if a find first / find next search returns a file named "." or ".."?
Are these volume labels or what? they are both present in every subdirectory except the root directory. I would prefer to exclude them from the list of file that are found how can I distinguish them from normal files or directories without resorting to checking the filename charictor by charictor here is a typical output screen in this case its the fasm directory the top two are what Im talking about

Code:
.
..
CODE
EXAMPLES
INCLUDE
SOURCE
    
Post 24 Apr 2007, 16:00
View user's profile Send private message Reply with quote
HyperVista



Joined: 18 Apr 2005
Posts: 691
Location: Virginia, USA
HyperVista 24 Apr 2007, 17:00
I believe they represent top of the current directory and root directory.

For example, when you open a DOS shell and type "cd .." it takes you to the top of the current directory.
Post 24 Apr 2007, 17:00
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 24 Apr 2007, 17:02
"." <- Current directory
".." <- Parent directory

The same happens with the FindFirst/FindNext API functions on Windows, I don't know how to exclude those directories neither Sad (without post processing)
Post 24 Apr 2007, 17:02
View user's profile Send private message Reply with quote
rain_storm



Joined: 05 Apr 2007
Posts: 67
Location: Ireland
rain_storm 24 Apr 2007, 20:25
Ah thanks guys I dont mind having them in there now that I know what they are. This was really confusing me I didnt know what they were so I thought I would ask
Post 24 Apr 2007, 20:25
View user's profile Send private message Reply with quote
eek



Joined: 21 Oct 2006
Posts: 24
eek 25 Apr 2007, 09:38
I can dodge them . and .. bits by just using the archive switch kinda thing

mov cx,00100000

mov cx,00100001

whatever...

The 00010000 switch brings them up

(I only do DOS btw)

A search on "Directory attribute flags" will show you
Post 25 Apr 2007, 09:38
View user's profile Send private message Reply with quote
Hayden



Joined: 06 Oct 2005
Posts: 132
Hayden 26 Apr 2007, 17:50
To look for everything except the volume label, set the hidden, system, and subdirectory bits all to 1.

Code:
MOV CX, 00010110b ; file attributes ( same as dos function 43h )
    


Download dosref33.zip from here: http://board.flatassembler.net/topic.php?t=6950

Chapter 4 has all the info you need for theese functions.
Chapter 5 has the layout for the DTA.

_________________
New User.. Hayden McKay.
Post 26 Apr 2007, 17:50
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 24 May 2007, 06:18
See my wimpy dir lister examples here.

BTW, you don't have to reset the DTA (defaults to PSP:80h) unless you need that space for cmdline opts (i.e., haven't read 'em yet).

Also, HelpPC (for whatever reason) claims that the responsibility of finding specific attribs is the user's job, not the OS's (so, I dunno, maybe some old DOS didn't respect it and just returned everything). Anyone know for sure from experience?
Post 24 May 2007, 06:18
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.