help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: filesep on Windows


From: Brennwald Matthias (bwm)
Subject: Re: filesep on Windows
Date: Wed, 24 Oct 2007 12:05:50 +0200


On Wed, 2007-10-24 at 03:44 -0500, address@hidden wrote:
>
> | Dear all
> |
> | A colleague encountered an error while running some of my code on
> his 
> | Windows machine with Octave 2.9.15. I've tracked the problem down
> to 
> | the fact that on Windows the file separator can be both '/' and
> '\' 
> | within a single path, whereas the filesep function returns only '\':
> |
> | ---------------------
> | which('mataa_path.m')
> | which: `mataa_path.m' is the script file
> | c:/octave/mataa/mataa_tools\mataa_path.m
> |
> | filesep
> | ans = \
> | ---------------------
> |
> | What is the logic behind using two different types of file
> separators 
> | on Windoze?
>
> As far as I can tell from looking at the code, the which function is
> ultimately looking through the load path and once it finds the file,
> it concatenates the directory where the file is found with the file,
> separated by filesep.  So what does
>
>   path
>
> print on the Windows system?  I'd guess it includes
>
>   c:/octave/mataa/mataa_tools
>
> I'm not sure why forward slashes are used here instead of filesep.
> How was that directory added to the path?

I cannot tell for sure, but I instructed my colleague to add the path
using the addpath(...) command, and I gave him an example using '/' in
addpath (I am pretty sure that's what he did).

I feel that mixing different fileseps is not a great idea. I believe
that fileseps should be harmonized somehow. I think it would be natural
if the user could specify paths using both '/' and '\' (so that both
addpath('path/to/my/file') and addpath('path\to\my\file') would work on
all platforms), and that Octave functions always return paths using only
the filesep of the platform it is running on (as returned by the filesep
function). Is that a good idea? How is the competition (aka Matlab)
doing it?

Matthias


reply via email to

[Prev in Thread] Current Thread [Next in Thread]