GetFullPath

버전 1.11.0.0 (19.7 KB) 작성자: Jan
Full path name for partial or relative path
다운로드 수: 7.1K
업데이트 날짜: 2021/6/20

라이선스 보기

편집자 메모: This file was selected as MATLAB Central Pick of the Week

GetFullPath - Get absolute path of a file or folder name
This function converts a partial or relative name to an absolute full path name. The fast Mex works on Windows only, but the M-file runs on Windows, MacOS and Unix.
FullName = GetFullPath(Name, Style)
INPUT:
Name: Char, string or cell string, file or folder name with relative or absolute path.
UNC paths accepted. Path need not exist.
Style: Special styles for long file names under Windows:
'auto': Add '//?/' for long names (> 255 characters). (default)
'lean': No '//?/'.
'fat': '//?/' added for short names also.
OUTPUT:
FullName: Char or cell string, file or folder name with absolute path.
EXAMPLES:
cd(tempdir); % Assuming C:\Temp here
GetFullPath('File.Ext') % ==> 'C:\Temp\File.Ext'
GetFullPath('..\File.Ext') % ==> 'C:\File.Ext'
GetFullPath('.\File.Ext') % ==> 'C:\Temp\File.Ext'
GetFullPath('*.txt') % ==> 'C:\Temp\*.txt'
GetFullPath('D:\Folder1\..\Folder2') % ==> 'D:\Folder2'
GetFullPath('\') % ==> 'C:\', current drive!
GetFullPath('Folder\') % ==> 'C:\Temp\Folder\'
GetFullPath('\\Server\Folder\Sub\..\File.ext')
% ==> '\\Server\Folder\File.ext'
Alternatives:
WHICH: only for existing files, ~24 times slower.
System.IO.FileInfo: .NET (thanks Urs), more features, ~50 times slower.
java.io.File: "/.." and "/." are fixed by getCanonicalPath (~6 times slower),
but no completing of partial/relative path.
Tested: Matlab 2009a, 2011b, 2018b, WinXP/32, Win7/64, Win10/64
Installation: See ReadMe.txt
Suggestions and question by email or in the comment section are very welcome.

인용 양식

Jan (2024). GetFullPath (https://www.mathworks.com/matlabcentral/fileexchange/28249-getfullpath), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2018b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 File Name Construction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.11.0.0

Typo fixed in InstallMex. No changes in actual function.

1.10.0.0

Unit test function added

1.9.0.0

Accept strings as input.

1.8.0.0

Bugfix in M-File for UNC path.

1.7.0.0

Unit test fixed: Consider buggy FULLFILE ov Matlab >= 2015b: FULLFILE('C:\', '\') replies 'C:\\' !
Improved handling of inputs with '//?/' prefix. 2nd input to control prefix in the output. New InstallMex function.

1.6.0.0

C-Mex tested under Win7/64. Improved UNC path support in the M-file. Bugfix for M-file under Linux (thanks Daniel).

1.5.0.0

Minor bug: '***' in the ErrorID caused bad messages in case of errors.

1.4.0.0

Bugfix in M-version: Treat empty matrix as empty string.

1.3.0.0

Accept cell strings as inputs.

1.2.0.0

M-Version replied bad path for input with leading separator. GetFullPath('\') is the current drive on Windows.

1.1.0.0

Doc updated, function not touched.

1.0.0.0