ensuredirexists.m
来自「显著区域检测。求的图像中感兴趣区域的位置」· M 代码 · 共 57 行
M
57 行
% ensureDirExists - makes sure that directory exists.%% ensureDirExists(directory) checks if directory exists% and attempts to create it if it doesn't exist. % This file is part of the SaliencyToolbox - Copyright (C) 2006-2007% by Dirk B. Walther and the California Institute of Technology.% See the enclosed LICENSE.TXT document for the license agreement. % More information about this project is available at: % http://www.saliencytoolbox.netfunction ensureDirExists(directory)global PD;% does directory alread exist?if ~isempty(dir(directory)) returnend% need to create directory - first figure out the base directoryslash = find(directory == PD);if isempty(slash) basedir = '.'; cdir = directory;else if (slash(end) == length(directory)) if (length(slash) == 1) basedir = '.'; cdir = directory; else basedir = directory(1:slash(end-1)); cdir = directory(slash(end-1)+1:end); end else basedir = directory(1:slash(end)); cdir = directory(slash(end)+1:end); endend% does the base directory exist?if isempty(dir(basedir)) fatal(['Could not create ' directory ... ', because the basedir ' basedir ' does not exist.']);end% last char of cdir is a slash? Need to remove itif (strcmp(cdir(end),PD)) cdir = cdir(1:end-1);end% now try making the directory[success, message] = mkdir(basedir,cdir);if ~success fatal(['Failed to create ' directory ' - error message: ' message]);end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?