This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to remove a non-empty directory in C++?
I have the directory name. i am trying remove(dir_name), but as the directory is not empty its returning false.
How can i delete the directory. Is there any built-in function which i can call??
To recursively remove a directory and all it's contents, use the following command in a terminal:
rm -rf /path/to/dir
Edit: Seems I was confused by your mention of built-in function, I was assuming a function "built into" linux. Obviously this is not C++ code. If that's what you want, see the question linked to in Fred Larson's comment to your original question.
Related
This question already has an answer here:
How to compile a cpp file directly from vim editor in Windows?
(1 answer)
Closed 2 years ago.
I've recently installed Vim on my Windows 10 and also the g++ compiler through mingw.
I want to directly compile and run my cpp program from Vim.
I've tried the following command.
:!g++ hello.cpp -o hello
below is the image for the reference
https://imgur.com/iYe0aVv
Probable answer to your problem: give the full paths: % for the source and %< for the executable.
Also, please, copy the message, avoid screenshots.
And finally, you should have a look at this question from this morning... IOW, prefer using quickfix feature. How to compile a cpp file directly from vim editor in Windows?
Regarding the execution on the current (monofile) program, it's
:!./%<
" or
:term ./%<
(you may have to add .exe after %<. IIRC, this is not necessary)
This question already has answers here:
In CMake, how can I find the directory of an included file?
(4 answers)
Closed 4 years ago.
I'm writing a .cmake file that handles a bunch of stuff and needs access to an executable in a fixed relative path to the .cmake file. In this instance, the orgianization looks like this:
CMakeLists.txt
- cmake
- tools.cmake
- bin
- exectuable.exe
The issue is that tools.cmake is included using include and thus, CMAKE_CURRENT_SOURCE_DIR returns the directory of the CMakeLists.txt. The reason I don't want to hardcode the path is that I want to put the tools.cmake and binary in a separate GIT repository and I don't want to force the user to place it in some specific folder.
Only solution I can come up with right now is to supply a function that sets and stores the path to tools.cmake. That's not really elegant.
Answered here: https://stackoverflow.com/a/12854575/2532768
CMAKE_JUCE_TOOLS_PATHdoes not return the correct path within functions or macros in tools.cmake but it results in the correct path outside any function. So one can us
set(PATH_TO_TOOLS_CMAKE ${CMAKE_JUCE_TOOLS_PATH})
to store the path while it can be accessed in a variable and than access PATH_TO_TOOLS_CMAKE in functions and macros
This question already has answers here:
Rename files and directories recursively under ubuntu /bash
(8 answers)
Closed 5 years ago.
I am using this command to replace a word with another in many filenames (batch):
rename 's/oldname/newname/g' **
But it works for the current open folder only. I am not sure how to make it work for that directory and all the sub-directories.
Thanks.
Mike,
Try this: Create new folders, move files, delete old folder. Then, move over directories.
Regards
This question already has answers here:
How can I do a recursive find/replace of a string with awk or sed?
(37 answers)
Closed 5 years ago.
I have a bash script that does the following:
Removes a CSS directory
Copies over new SASS from source
Runs gulp task to generate CSS again
After I copy the SASS over, I would like to do the following before generating CSS again:
Find any occurrence of ('/assets and change it to ('/themes/custom/mytheme/assets in any of the files in the SASS directory.
How can I do that?
As was already mentioned, this can be done for example with a basic sed substitution. The only thing to look out for, is to escape the slashes and to use -i to edit files in place.
sed -i "s/('\/assets/('\/themes\/custom\/mytheme\/assets/" /path/to/SASS/*
This question already has answers here:
Why do you need ./ (dot-slash) before executable or script name to run it in bash?
(9 answers)
Closed 7 years ago.
I am working with this c++ project for making command line text editor like Vim. The documentation tells that in order to run this text editor in terminal you need to write command ./main in the project folder.
The project folder has main.cpp file. Is this a command to execute that file (may be I am wrong) or this command is a standard terminal command.
Thank you.
Running ./main means run main from the current directory (.).
The current directory is normally missing from $PATH so you have to specify it explicitly.