Movatterモバイル変換


[0]ホーム

URL:


CFEngine documentation homepage

fileexists

Suggest changes
Table of contents

Prototype:fileexists(filename)

Return type:boolean

Description: Returns whether the filefilename can be accessed.

The file must exist, and the user must have access permissions to the file forthis function to return true.

Notes:

  • fileexists() doesnot resolve symlinks. If a broken symlink exists, thefile is seen to exist. For this functionality usefilestat("myfile", "link target")to see if a file resolves to a the expected target, and check if thelink target exists. Alternatively usetest withreturnszero(), for examplereturnszero("/bin/test -f myfile").

Arguments:

  • filename:string - File object name - in the range:"?(/.*)

Example:

code
bodycommoncontrol{bundlesequence=>{"example"};}bundleagentexample{classes:# this.promise_filename has the currently-executed file, so it# better exist!"exists"expression=>fileexists($(this.promise_filename));"exists_etc_passwd"expression=>fileexists("/etc/passwd");reports:exists::"I exist!  I mean, file exists!";}

Output:

code
R: I exist!  I mean, file exists!

See also:filestat(),isdir(),islink(),isplain(),returnszero()

Still need help?

Chat Ask a question on Github Mailing list
Version 
master3.24 (LTS)3.21 (LTS)view all versions

[8]ページ先頭

©2009-2025 Movatter.jp