Home > core > findRAVENroot.m

findRAVENroot

PURPOSE ^

findRAVENroot

SYNOPSIS ^

function [ravenPath, prevDir] = findRAVENroot()

DESCRIPTION ^

 findRAVENroot
   Finds the root of the RAVEN directory, first by  by searching for the path to
   RAVEN2.png. Can also record the current directory, in case a function will
   use the ravenPath to navigate to a precise folder, and it should return to
   the previous directory afterwards. See e.g. optimizeProb calling glpk.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ravenPath, prevDir] = findRAVENroot()
0002 % findRAVENroot
0003 %   Finds the root of the RAVEN directory, first by  by searching for the path to
0004 %   RAVEN2.png. Can also record the current directory, in case a function will
0005 %   use the ravenPath to navigate to a precise folder, and it should return to
0006 %   the previous directory afterwards. See e.g. optimizeProb calling glpk.
0007 
0008 ST=dbstack('-completenames');
0009 prevDir = pwd();
0010 if ispref('RAVEN','ravenPath')
0011     ravenPath = getpref('RAVEN','ravenPath');
0012 else
0013     ravenPath = ST(strcmp({ST.name},'findRAVENroot')).file;
0014     rootFound = 0;
0015     while rootFound == 0
0016         isRoot = isfile(fullfile(ravenPath,'RAVEN2.png'));
0017         if isRoot
0018             rootFound = 1;
0019         else
0020             ravenPathOld = ravenPath;
0021             ravenPath = fileparts(ravenPath);
0022             if strcmp(ravenPathOld,ravenPath)
0023                 error('Cannot find the RAVEN root directory. Make sure you have not removed the RAVEN2.png file from your RAVEN installation.')
0024             end
0025         end
0026     end
0027 end

Generated by m2html © 2005