Jump to content

How do I make a Func IsDirectory()


Skizmata
 Share

Recommended Posts

Func _IsDirectory($s_file)
    Return StringInStr(FileGetAttrib($s_file), "D")
EndFunc

Very close to mine! The only diffrence is that yours will return the offset of the letter D, which should be 3?

A better Idea would be to do this:

Func _IsDirectory ($sDir)
   Return StringInStr (FileGetAttrib ($sDir), "D") <> 0
EndFunc ; ==> _IsDirectory

Mat

Link to comment
Share on other sites

  • Moderators

Very close to mine! The only diffrence is that yours will return the offset of the letter D, which should be 3?

A better Idea would be to do this:

Func _IsDirectory ($sDir)
   Return StringInStr (FileGetAttrib ($sDir), "D") <> 0
EndFunc ; ==> _IsDirectory

Mat

If you want a boolean return sure. But as far as "Better", not quite sure where that comes into play.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Link to comment
Share on other sites

Additionnally _IsFile (not a directory but really a file)

Func _IsFile ($sFile)
Return Not(StringRegExp (FileGetAttrib ($sFile), "D", 0))
EndFunc ; ==> _IsFile

This return a boolean (true/false)

OR

Func _IsFile ($sFile)
Return Not(StringRegExp (FileGetAttrib ($sFile), "D", 0)) + 0
EndFunc ; ==> _IsFile

This return a number (0(is not a file)/1(is a file))

I can't really test since I use v3.2.0.1

and I don't have StringRegExp but it should work

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...