Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检查Phing中是否存在目录并提示继续?_Php_Phing - Fatal编程技术网

Php 检查Phing中是否存在目录并提示继续?

Php 检查Phing中是否存在目录并提示继续?,php,phing,Php,Phing,我试图检查Phing中是否存在一个目录或文件,但我甚至无法使基础工作正常进行 例如: 是的 我得到一个奇怪的错误: Error reading project file [wrapped: \build.xml:22:18: Error initializing nested element <echo> [wrapped: phing.tasks.system.IfTask doesn't support the 'echo' creator/adder.]] 读取项

我试图检查Phing中是否存在一个目录或文件,但我甚至无法使基础工作正常进行

例如:


是的
我得到一个奇怪的错误:

Error reading project file [wrapped: \build.xml:22:18: Error initializing nested  
element <echo> [wrapped: phing.tasks.system.IfTask doesn't support the 'echo' 
creator/adder.]]
读取项目文件[wrapped:\build.xml:22:18]时出错:初始化嵌套 元素[wrapped:phing.tasks.system.IfTask不支持“echo” 创建者/加法器。]] 最后,我想添加一个条件yes/no,以便在目录存在时继续


注:据我所知,该错误与“嵌套元素echo”无关,因为如果我删除了echo,它仍会发送相同的错误,事实上我认为这是一条默认的语法相关错误消息或其他信息。

如果您只需删除目录,则只需调用delete即可。Phing将自动检查您是否存在该文件,因此您无需进行检查:

<target name="clean">
    <delete
      dir="${project.basedir}/${source.directory}" quiet='true'
    />
</target>

此处的重要删除属性包括:

以下功能在我的系统中运行良好:

<target name='test'>
  <if>
    <available file='results' type='dir' />
    <then>
      <echo>Yep</echo>
    </then>
  </if>
</target>

是的

因此,我认为您使用AvailableTask的方式是不正确的。

这不是我要尝试的,只是一个例子。实际使用提示用户选择是/否以决定是否删除,如
rm-i
,似乎
没有此运算符。请注意,可用任务需要属性属性(强制)-@tomasrado
属性
属性在使用
可用
作为条件时不是强制的
<target name='test'>
  <if>
    <available file='results' type='dir' />
    <then>
      <echo>Yep</echo>
    </then>
  </if>
</target>