What's the right include/exclude pattern to exclude content of a folder but include the folder itself ?
for example,
I want to exclude all classes and all the package structure in WEB-INF/classes, but keep the folder itself.
Assuming the following directory str.:
..\ tarring \ xyz \ folder-A;
..\ tarring \ xyz \ folder-B;
...
..\ tarring \ xyz \ folder-X;
<tar basedir="..\tarring\xyz" destfile="..\tarring\xyz.tar">
<exclude name="folder-X/**/*"/>
</tar>
folder-X: the folder which is to be included in the tar file, but without its contents
xyz.tar will contain all the contents within the ..\ tarring \ xyz folder, along with an empty folder-X.
<exclude name="folder-X/**/*"/> : includes ONLY folder-X and not inner files or sub-directories
<exclude name="folder-X/**/*.*"/> : includes folder-X along with all sub-directories under it. However, excludes ALL files within folder-X and its sub-directories.
<exclude name="folder-X/*.*"/> : includes folder-X and any sub-directories within folder-X, along with all their contents BUT excludes all FILES directly under folder-X
Related
I have read the manual at https://cppcheck.sourceforge.io/manual.pdf and have found that I can use -i to ignore a directory. However, in my testing it doesn't seem to ignore the whole subdir. Example, I have a library that has a very long directory path (this is simplified) but I want to ignore everything under the top level
Root
> Lib
>> Lib dir 1
>>> file.c
>> Lib dir 2
>>> file.c
The wording
To ignore certain folders you can use -i. This will skip analysis of source files in
the foo folder.
cppcheck --project=compile_commands.json -ifoo
Suggests that it will skip any files in the specified dir, not any subdirs.
Is there a way to skip the dir and all sub dirs?
The way I had to achieve this was generating a compile_commands.json from cmake then write a python script to exclude anything that matched the filter I wanted to exclude, eg /libA/ will exclude anything under libA
I have a project folder with several directories
- archive
- include
- lib
- src
- src/obj (obj is a subdirectory of src)
I would like tar to pack these directories and their contents into a main.tar, then I will the main.tar into the archive directory.
tar cvz \
--exclude="*.obsolete" --exclude="*DS_Store" --exclude="./archive/*" \
-f main.tar \
./archive ./include ./lib ./src
I would like to exclude the contents of the archive directory but still package the empty directory itself. You can see I am also excluding some other stuff from various places, OSX likes to write .DS_Store files everywhere on my filesystem and I occasionally make copies of files and append .obsolete to the end while working on a new version.
Unfortunately, the empty archive directory is not included in main.tar.
According to this thread, my command should work.
How can the files be excluded from archive but the empty directory be packed into the tar file?
edit
The following fails:
--exclude="./archive/*"
The following works:
--exclude="./archive/*.*"
So the whole command is:
tar cvz \
--exclude="*.obsolete" --exclude="*DS_Store" --exclude="./archive/*.*" \
-f main.tar \
./archive ./include ./lib ./src
I want to preserve the ".git" directory with all of it's content while executing synk ant task, but it deletes the content of .git directory.
<sync todir="${local.git.dir}" includeEmptyDirs="true">
<fileset dir="${img.dir}"/>
<preserveintarget>
<include name=".git"/>
</preserveintarget>
</sync>
Why according to this syntax, synk deletes the content of the .git directory?
This synk task should copy the file f1 (dir="${img.dir}") into the directory dir1 (todir="${local.git.dir}"); dir1 contains the directory .git.
Synk task doesn't delete the content of the .git directory only if I mention to put the file f1 into the directory dir1/target. In this case I will have this structure:
dir1 contains the directories: .git and target
the file f1 is copied into the target directory (which I don't want)
I want dir1 to contain .git and f1.
I found the problem. I didn't specified to preserve the files in the .git.
By appending /** to .git I resolved the problem: <include name=".git/**"/> instead of <include name=".git"/>
i have a list of paths to sources in subfolders of /source in $(SOURCES). Paths are like this:
$(SOURCES)=
source/main.cpp
source/subfolder/code.cpp
....
how can i convert all of 'em in this format?
$(OBJECTS)=
obj/main.o
obj/code.o
....
or at least how to automatically create all the missing folders in obj/ and change "source" to "obj" in paths?
I need to copy the zip files from local machine and paste in remote machine and unzip those files in remote machine.
I know the first part can be done using the scp (copy zip files from local and paste in remote machine) but how to do the second part using ant?
Thanks in advance
You could use the sshexec task to call the command line unzip command on the remote machine (assuming the remote machine has unzip installed).
<!-- local directory containing the files to copy -->
<property name="archives" location="C:\path\to\zipfiles" />
<property name="archives.destination" value="/home/testuser/archives" />
<property name="unzip.destination" value="/home/testuser/unpacked" />
<fileset id="zipfiles.to.copy" dir="${archives}" includes="*.zip" />
<!-- copy the archives to the remote server -->
<scp todir="${user}:${password}#host.example.com:${archives.destination}">
<fileset refid="zipfiles.to.copy" />
</scp>
<!-- Build the command line for unzip - the idea here is to turn the local
paths into the corresponding paths on the remote, i.e. to turn
C:\path\to\zipfiles\file1.zip;C:\path\to\zipfiles\file2.zip... into
/home/testuser/archives/file1.zip /home/testuser/archives/file2.zip
For this to work there must be no spaces in any of the zipfile names.
-->
<pathconvert dirsep="/" pathsep=" " property="unzip.files" refid="zipfiles.to.copy">
<map from="${archives}" to="${archives.destination}" />
</pathconvert>
<!-- execute the command. Use the "-d" option to unzip so it will work
whatever the "current" directory on the remote side -->
<sshexec host="host.example.com" username="${user}" password="${password}"
command="/bin/sh -c '
for zipfile in ${unzip.files}; do
/usr/bin/unzip -d ${unzip.destination} $$zipfile ; done '" />
The unzip command can take a number of other options, see its man page for full details. For example the -j option will ignore any directory hierarchy inside the zip files and put all the extracted files directly in the target directory. And -o will force overwrite existing files in the target directory without prompting.