我可以将文件写入 linux 目录并在 cfscript 中指定文件权限吗?

Can I write a file to a linux directory specifying file permissions in cfscript?

我有一个函数可以将 coldfusion 查询结果作为文件写入临时目录。它工作正常,并且不必如此频繁地 运行 查询。

但是,我想写一个 git 钩子来删除这些缓存文件,因为当我们推送新代码时,数据可能已经过时,因此应该被替换。这些文件由 apache 用户以 644 模式创建。 git 用户与 apache 用户在同一组中,因此为了让 git 用户能够删除文件,我想创建它们,或者随后将它们设置为 664 模式。

最初我在我使用的 objectSave 之后添加了 fileSetAccessMode:

objectSave( data, filepath );
fileSetAccessMode( filepath, '664' )

然而这似乎没有任何效果,所以尝试了

fileWrite( filepath, data, '664' );

这似乎也可以很好地写入文件,但没有设置权限。

我注意到 Adobe Docs for fileWrite don't specify a parameter for mode, so I guess that's why that doesn't work. I much prefer cfdocs.org in general but I was quite confused by their take on the cfscript versions of cffile,因为哪个函数使用了哪个参数并不明显。

经过更多谷歌搜索后,我发现了这个 cflib.org cftag style function,我想我可以在 cfscript 中借用和参考它,但我真的不想那样做。

我真正想知道的是,我能否仅在 cfscript 中实现此目的,或者脚本和标记之间的 API 功能是否存在真正的区别? (我很确定在其他情况下也是如此)。

非常感谢任何意见。

休息一会再回到这里,我发现我可以使用

fileSetAccessMode( file, '664' );

在 cfscript 中,令人尴尬的是我把它放在了错误的代码位置。但是,仍然有必要在之前创建文件后单独执行此操作,因为

fileWrite( file, content );

不支持 "mode" 参数,如

<cffile action="write" file="file" output="content" mode="664">

consulted with some wiser members of the community, I have filed this as a bug with Adobe.