Jump to content

FileExist ( and other ) strange behavior


Terenz
 Share

Recommended Posts

Someone can explain me why with dots the path change and it's considered the "level up" path? In the help i don't have found nothing about this:

ConsoleWrite(FileExists("C:\.") & @CR)
ConsoleWrite(FileExists(@DocumentsCommonDir & "\..") & @CR)

Local $search = FileFindFirstFile(@DocumentsCommonDir & "\..")

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    Local $file = FileFindNextFile($search)
    If @error Then ExitLoop

    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)

The result of the search is "All Users" :sweating:

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

The dot thing stems from the days of DOS, where a single dot and backslash meant use current folder, whereas two dots meant use parent folder of current folder, and three dots (with another backslash after first dot) meant use the parent folder of that folder, and so on.

However, as jguinch wrote, you need the wildcard filter of asterisks (*.*), and not more than one dot usually.

The first asterisk, designates any file name in specified directory, while the second asterisk designates any file extension.

If you only wanted a specific extension, like .txt, then you would use (*.txt) to get all text files in specified directory.

Local $search = FileFindFirstFile(@DocumentsCommonDir & "\..\*.txt")

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Maybe i wasn't clear, why we have this "dots" feature? Why there isn't any trace in the help? In my point of view FileExist with a folder with dots at the end need to return 0 and not 1, just for make an example, and not check if parent folder exist or not.

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

This "feature" has been in DOS/Windows for too long to be changed now and many functions in AutoIt merely wrap Windows API. The help is about AutoIt, it isn't a Windows summary.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

jchd is completely right, and your use in OP is not standard.

In fact, I'd go as far as saying it is incorrect use, though obviously you can get away with it to some degree.

Perhaps you should have used

Local $search = FileFindFirstFile(@DocumentsCommonDir & "\..\*")

or

Local $search = FileFindFirstFile(@DocumentsCommonDir & "\..\*.*")

I don't know though, because I've never tried either.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...