[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
proposed fileparts patch
From: |
John W. Eaton |
Subject: |
proposed fileparts patch |
Date: |
Thu, 23 Oct 2008 14:58:27 -0400 |
On 23-Oct-2008, Hall, Benjamin wrote:
| Matlab accepts both "/" and "\" as valid path separators on windows. The
proposed patch below would update fileparts to behave consistently with matlab
and correctly identify paths with mixed file separators when used in windows.
|
|
|
|
| *** fileparts.orig.m Thu Oct 23 14:34:47 2008
| --- fileparts.m Thu Oct 23 14:37:42 2008
| *************** function [directory, name, extension, ve
| *** 27,33 ****
|
| if (nargin == 1)
| if (ischar (filename))
| ! ds = rindex (filename, filesep);
| es = rindex (filename, ".");
| ## These can be the same if they are both 0 (no dir or ext).
| if (es <= ds)
| --- 27,44 ----
|
| if (nargin == 1)
| if (ischar (filename))
| ! if ( ispc )
I'd prefer to avoid checks for "ispc" in the Octave sources if
possible.
In the C++ sources, we have file_ops::is_dir_sep, which will return
true for either / or \ on Windows systems. Perhaps we should export
it in some way to the scripting language? Or we could have another
function that produces a list of file separators, like the
file_ops::dir_sep_chars function does in the C++ sources.
jwe