In eclipse CDT 4.2 i want to include only few folders as resource.
eg "/root" is the place where project "myproject" is created. I want to include only these folders and exclude any others.
/root/A
/root/B
/root/C/D
I am aware that this can be done in
Project -> Resource -> Resource Filters
But the UI there is confusing me.
What is the difference between Location and Relative path.
The check box "Apply recursively" is also confusing me a bit.
There is a way to specify regular expression but if I put a regex starting with *, like */root/A/* or */myproject/A/* it will give error saying "Dangling meta character near index 0".
In short because of these seemingly confusing options (to me) I am not yet able to acheive above. Please clarify
PS : The way source lies in linux my file system and proprietary source control system they all are links. Not sure if this matters , but just mentioning.
eg
root/A/file.c --> [link to version control system for file.c]
What is the difference between Location and Relative path.
The Location is the full path (e.g. /home/user123/workspcae/proj1/src/foo.c), where relative path is only the part within the project directory (e.g. src/foo.c)
The check box "Apply recursively" is also confusing me a bit.
Means the rule is not only used for the projet-root, but also for any sub-directory. I.e. a rule to match src/*.c won't do anything without "Apply recursivly", because it only matches files in the sub-directory src
There is a way to specify regular expression but if I put a regex starting with *, like /root/A/ or /myproject/A/ it will give error saying "Dangling meta character near index 0".
You are using wildcards, not regular expressions. regex are much more complex, and stars mean the previous 'object' may occur zero or more times. Without this previous object Eclipse gets confused. Just don't check the regex-box and it should work as you expected, or add a dot before the star, meaning any character.
To Solve your Problem do:
Project -> Properties -> Resource -> Resource Filters
Include only:
Folder: (name match) a
Folder: (name match) b
Folder: (name match) c
Exclude all:
Files: (name match) *
Folder c -> Properties -> Resource -> Resource Filters
Include only:
Folder: (name match) d
Exclude all:
Files: (name match) *
Related
I use Atom as my primary coding environment, and generally I love it. There is one feature that I could really use right now, and I'm not sure if it exists or not.
Basically, I want to do a project-wide search for a string ("1.1.0"), but I only want to search within files that have the word "build" in them. I know that Atom allows me to search a file/directory pattern, such as src/assets or even src/assets/*.cs or src/assets/buildFile.*
But in this particular project there are tons of files that have the world build - CustomBuild.xml, BuildScript.cs, FinalBuild.xml, etc. Is there any way that I can tell Atom to search for my query string in a regex-defined file/directory pattern? (I'm also open to other ways of solving my problem)
Thank you for your time!
Update: Just to clarify, some things I've tried so far:
Searching using "*build*" for my file/directory pattern (only returns file names that are build.*)
Using */**/*build*.* (same issue)
In Visual Studio code, how do I search for just a specific file type (i.e. *.css or *.ts)?
PS: I'm talking about the global search (Ctrl+Shift+F in Windows)
I'm already using the "files to include" as a folder filter. So currently it has something like ./src/app.
Click the ellipses on the bottom right to display the "files to include" field.
You can specify a particular type with "*.filetype".
E.g.
You can do this.
./src/app/**/*.ts
other glob syntax
* to match one or more characters in a path segment
? to match on one character in a path segment
** to match any number of path segments, including none
{} to group conditions (for example {**/*.html,**/*.txt} matches
all HTML and text files)
[] to declare a range of characters to match (example.[0-9] to
match on example.0, example.1, …)
How can I list only files, but not directories using list.files (not recursively)? It has an include.dirs argument, but this is ignored when not being used recursively.
I had been thinking something like
list.files(path=myDir, pattern="[^/]$")
but that doesn't seem to work, or a few variations on it. Is there a regex that I can plug in here or a function. I know I can do list.dirs and take a setdiff, but this is already slow enough, I want this to be quicker.
PS: currently on linux, but need something that works cross-platform.
PPS: file.info is really slow, so I think that is also not going to work.
PPPS: It doesn't need to be list.files, that is just the function I had thought should do it.
Consider this regex pattern that matches any file containing letters or numbers and contains the dot extension (to leave out subdirectories but unfortunately files without extensions):
# WITH ANCHORING
files <- list.files(path, pattern=("[a-zA-Z0-9]*[.][a-zA-Z0-9]*$"))
# MATCHING LETTER AND/OR NUMBER FILES WITH EXTENSION
files = list.files(myDir, pattern=("[a-zA-Z0-9]*[.]"))
# WILDCARD FILE MATCHING WITH EXTENSION
files = list.files(myDir, pattern=("*[.]"))
Some other regex variations to catch files with periods (note these also get directories with periods and miss files with no extensions)
list.files(pattern="\\..+$")
list.files(pattern="\\.[[:alnum:]]+$")
And using system2 with ls seems to work pretty well (thanks #42- as well from comments),
system2("ls", args=c("-al", "|", "grep", "^-"))
should get only regular files (including ones without extensions), or
system2("ls", args=c("--classify"))
should return files with directories having a "/" appended so they can be determined.
For an alternative open-source solution, consider the Python solution that allows you to condition if item is a directory and using os.path.join() is agnostic to any OS platform.
import os
files = [f for f in os.listdir(myDir) if os.path.isfile(os.path.join(myDir, f))]
In Xcode, in this case 4.x, how would you go about excluding a path (or a path containing a pattern) from search results?
My use case:
My project is SVN controlled. Whenever I search for text (such as a function name), I often get irrelevant results returned from ".svn-base" files (which are used for making local diff's between your working copy and the last checked out revision).
I have setup a custom scope where the 'Location' 'is within the file or folder' 'Classes' (a subfolder I want to search). There doesn't seem to be a way to say "And Not..." or "And where path does not match". There is a "matches regex" and I feel the answer may lie around Look-arounds... Maybe something like (?!\.svn)?
In an extra condition in the settings of my custom scopes I use this:
^((?!\.svn).)*$
Check out this very good explanation here: stackoverflow
In building a C++ project with the GNU tool chain, make tells me ~
src/Adapter_FS5HyDE.d:1: *** multiple target patterns. Stop.
Search, search, search, and I found out that make thinks that it has multiple targets because the path to my included headers has spaces in it. If you've got your headers stored in some sane place like C:\Program Files then you can take care of this by using the old DOS paths (e.g. C:\PROGRA~1). However, when you have your headers in a truly insane place like My Documents you can get around the problem with MY DOC~1 because there's still a space.
Any idea how to tell my compiler to look in My Documents for headers without make confusing the path as two objects?
(Note: Feel free to throw tomatoes at me for putting header files in My Documents if you'd like, but there is a little rationale for doing that which I don't feel like explaining. If the solution to this question is easy, I'd rather keep it the way it is.)
You can figure out what the old path is by doing a DIR /X in your command prompt.
Or, most of the time you can fake it with the first 6 characters - spaces + ~1 + extension (8.3 paths won't have spaces).
Or, you can use quotes: "C:\Documents and Settings\Administrator\My Documents".
I don't know about make specficially, but the normal way around this is to put quotes around the path i.e.
cd "C:\Program Files\"
does that work?
Side note: the short name (8.3) for the same folder might not be the same on different OS installations. Thus, you can't be sure that C:\Program Files will always be C:\PROGRA~1.
Short names can't contain spaces in them either, so the usual short name for My Documents is MYDOCU~1, not MY DOC~1.
You can find the exact short name for any folder or file (including My Documents) using dir /x <filename>.
If you are using the GNU toolchain from Windows command line (cmd.exe), you should be able to use quotes (") around the folder/file names to work around this problem.
For some folders, including My Documents, you can specify an alternative location. To do this, right-click the folder, select Properties, select Location tab, and away you go. I use this to put my downloads and music on another drive (D:).
Write a wrapper script (e.g. batchfile) to translate the path names to short form.
I have a script "runwin" that does stuff like this - instead of, e.g. gcc <args> I can call runwin gcc <args>;
runwin will make heuristic guesses as to which arguments are filename paths and translate them, then call gcc on the resulting string of arguments.