I think Eric is really asking - if you have a directory (which may be empty or 
may contain files, subdirectories, etc), how do you tell if that directory is 
empty or not?

He states in his first message that he wants to know this because tar fails if 
you try to tar an empty directory.  You could set it to not fail on errors, but 
then you would ignore all errors - and if something else created an error when 
tarring, you might not want to ignore it.  Better to check first to see if the 
directory is empty, and only tar if it isn't.

Is there a way to tell if a fileset is empty?  If so, he could just create a 
fileset based on that dir and check it. I haven't found such a task if there is 
one.

Paul Faulstich

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 28, 2006 12:02 PM
To: [email protected]
Subject: AW: Check if files exist in a folder before I tar

<tstamp/>
<tar destfile="${backup.dir}/backup_${DSTAMP}_${TSTAMP}.tar">
    <fileset dir="${data.dir}">
        <modified/>
    </>
</>


Jan

>-----Ursprüngliche Nachricht-----
>Von: Eric Wood [mailto:[EMAIL PROTECTED]
>Gesendet: Dienstag, 28. Februar 2006 17:37
>An: Ant Users List
>Betreff: RE: Check if files exist in a folder before I tar
>
>I don't know the names of the files in the directory. I want to 
>determine if there are any files in the directory before I attempt to 
>tar.
>
>Eric
>
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, February 28, 2006 10:52 AM
>To: [email protected]
>Subject: AW: Check if files exist in a folder before I tar
>
><available property="file.present">
><target unless="file.present">
>    <untar/>
></target>
>
>
>Jan
>
>>-----Ursprüngliche Nachricht-----
>>Von: Eric Wood [mailto:[EMAIL PROTECTED]
>>Gesendet: Dienstag, 28. Februar 2006 16:50
>>An: [email protected]
>>Betreff: Check if files exist in a folder before I tar
>>
>>What is the easiest way to check if files exist in a folder prior to 
>>attempting to back them up via tar?
>>
>>Tar fails if I run it asking it to back up files and no files exist. 
>>
>>        <tar destfile="${backup.dir}/${current.dir}.tar">
>>            <tarfileset dir="${gen.dir}" >
>>                <include name="*.*" />
>>            </tarfileset>
>>        </tar>
>>
>>Eric
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED] For additional 
>commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED] For additional 
>commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: 
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to