フィルターのクリア

Get the path to the mat file that called my function?

9 ビュー (過去 30 日間)
gvoysey
gvoysey 2016 年 10 月 15 日
回答済み: Image Analyst 2016 年 10 月 15 日
I am writing a git library to do some code inspection and reporting. I intend to have it as its own package; let's call it `+git-injector`, and give it a method `report`.
I want to perform git operations on the repository that calls `git-injector.report()`. `matfilename` gives me the path to `report`, which is not helpful.
What options does matlab provide for reflection-type inspection so i can programmatically determine what the next frame up the stack from me was/ answer the question "who called me" inside of `report.m`?
What i want would probably look like this:
function status = report()
callingPath = fullfile(BLACK_VOODOO_MAGIC_REFLECTION_METHOD()); % get the path to the function that invoked me
% do some helpful stuff on that code's git information, if it exists.
status = get_repo_status(callingPath);
end

採用された回答

Image Analyst
Image Analyst 2016 年 10 月 15 日
You can get the call stack by calling dbstack(). Then you can find the file using dir() or which().

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSource Control Integration についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by