News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

exist

Started by oex, February 28, 2010, 02:52:51 AM

Previous topic - Next topic

oex

Is there an 'exist' function for directories? exist c:\dirpath without trailing backslash works but beeps :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Gunner

    invoke  SHGetFileInfo, addr MyDir,
                            NULL,
                            addr sfi,
                            sizeof sfi,
                            SHGFI_DISPLAYNAME


Seems to work for directories, not sure if it is the best way...  returns 0 if the directory does not exist and 1 if it does
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

hutch--

I know this is crude but I store the current path and change directory to a path to test. If it returns an error it does not exist. If it does not return an error I change back to the current path with a verified directory.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

sinsi

Use GetFileAttributes and test the return value for INVALID_FILE_ATTRIBUTES (error) then FILE_ATTRIBUTE_DIRECTORY.
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave


sinsi

GetFileAttributes takes 1 parameter (the name) and returns a dword, no need to allocate structures then close handles.
Light travels faster than sound, that's why some people seem bright until you hear them.

oex

:lol the only one I'd thought of was FindFirstFile.... let me rephrase which one's best

EDIT: Thanks Sinsi (and all :wink)will try that one then :bg
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Gunner

There are many ways to kill a bird  :bg  Didn't think about FindFirstFile.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

oex

You can kill a bird with FindFirstFile? :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

BlackVortex

SHGetFileInfo is brutally slow and too much for this simple task. I'd go with Sinsi's suggestion. Searching also found this thread :
http://www.masm32.com/board/index.php?topic=5259.0