wxWidgets: Is there a makedirs function that creates more non-existing subdirs along the path? - wxwidgets

Having a path (here Windows) like c:\MyPath\where\ the\part\of\it\does\not\exist. Is there any function in wxWidgeds that creates all the missing (bolded in the example) subdirectories, or do I have to write some on myself?
(If you know Python, the os.makedirs() is the equivalent.)
Thanks,
Petr

The easiest way to do this is to use the static function wxFileName::Mkdir and pass it the wxPATH_MKDIR_FULL flag.

Related

is there any way to splitting Variables in VSCode?

I wonder there is any way to splitting some variables in VSCode?
my example will explain my question better:
I have an exe file in such path C:\path\to\workspace\main\project\project.exe
my cpp source path that will create exe file is this C:\path\to\workspace\main\project\test.cpp
I want to create a task in tasks.json but my oder of variables does not give me the right path
as you understand:
${workspaceFolder} is C:\path\to\workspace
${fileDirname} returns C:\path\to\workspace\main\project
and ${relativeFileDirname}.exe returns main\project.exe
and combination of "${fileDirname}\\${relativeFileDirname}.exe" as a command will return C:\path\to\workspace\main\project\main\project.exe that is wrong.
so I wanted to know there is any other variable that just return the parent of current file or not?
if not can we split variables with \ ?
I hope it makes some sense
thanks
Add new fileDirnameBasename variable
see https://github.com/microsoft/vscode/commit/551db7ec94f02a4bdc8999092cf8bef642b3992d
${fileDirnameBasename} is being added to vscode v1.52 which I believe is what you are looking for.
You can use the extension Command Variable
Use the commands:
extension.commandvariable.file.fileDirBasename
extension.commandvariable.file.fileDirBasename1Up
extension.commandvariable.file.fileDirBasename2Up
btw, as an workaround, this worked for me
"${fileDirname}\\*.exe"
but need a variable for getting parent folder of current open file
any idea?

Golang - How to check a function is referenced in other source file?

I'm a fresh man of golang and here is my problem:
I have a array of function names like this: [FunctionA FunctionB]
I want to check if those functions are referenced in other source files like: somefile.go.
What is the best way to achieve this?
In one word: How can I verify some functions are used in other source files in golang?
[Update]
Yes, it's something like grep -rl "funcName" files, but how can I omit comments in this case?

wxWidgets: Are there functions for a path manipulation? (Split to subdirs, join, ...)

Having a path in a wxString variable, how do you append a subdirectory? Are there any specific functions for working with paths?
For those of you who know the Python language, there are nice functions like os.path.join("sub1", "sub2", "sub3"...) that joins the subX parts using the OS specific separator, and the os.path.split(path) that splits the path to the directory and the last name. The os.path.join() is nice even in situations when you are sure what separator can be used.
Thanks for your time and experience,
Petr
P.S. I am interested in the lastest wxWidgets version (2.9.4+).
wxFilename does what you need.
http://docs.wxwidgets.org/trunk/classwx_file_name.html
so, for example
wxFileName fname;
fname.AppendDir("sub1");
fname.AppendDir("sub2");
fname.SetName("test");
fname.SetExt("txt");
will create on windows
sub1\sub2\test.txt

CMake: Get the complete representation of a path minus relative elements

I want to take a variable that has been set to a combination of path elements (potentially both absolute and relative) and get the absolute path from it. Something like what boost::filesystem::system_complete() does in C++. For example, I have something like:
set(EXTERNAL_LIB_DIR "${CMAKE_SOURCE_DIR}/../external" CACHE PATH "Location of externals")
which works but in the UI it's a bit ugly, as it might end up looking like C:/dev/repo/tool/../external. I'm wondering if there's a CMake built-in command to turn that into C:/dev/repo/external before I go and script a macro to do it. find_path kind of does this, but it requires that the path already exist and something worth searching for be there. I want it to work whether the path exists or not (I might use it for an overridden CMAKE_INSTALL_PREFIX default, for example).
You can use:
get_filename_component(NEW_VAR ${EXTERNAL_LIB_DIR} REALPATH)
As of CMake 3.20, you can use the cmake_path command to normalize the path, which supersedes the get_filename_component command.
cmake_path(SET MY_NEW_PATH NORMALIZE ${EXTERNAL_LIB_DIR})
This also converts any backslashes (\) into forward-slashes cleanly.

Matlab can't find member functions when directory changes. What can I do?

I have a Matlab program that does something like this
cd media;
for i =1:files
d(i).r = %some matlab file read command
d(i).process();
end
cd ..;
When I change to my "media" directory I can still access member properties (such as 'r'), but Matlab can't seem to find functions like process(). How is this problem solved? Is there some kind of global function pointer I can call? My current solution is to do 2 loops, but this is somewhat deeply chagrining.
There are two solutions:
don't change directories - instead give the file path the your file read command, e.g.
d(i).r = load(['media' filesep 'yourfilename.mat']);
or
add the directory containing your process() to the MATLAB path:
addpath('C:\YourObjectsFolder');
As mentioned by tdc, you can use
addpath(genpath('C:\YourObjectsFolder'));
if you also want to add all subdirectories to your path.
Jonas already mentioned addpath, but I usually use it in combination with genpath:
addpath(genpath('path_to_folder'));
which also adds all of the subdirectories of 'path_to_folder' as well.