[Top][All Lists]

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

Re: Yet Another Plotting System for Octave

From: John W. Eaton
Subject: Re: Yet Another Plotting System for Octave
Date: Thu, 18 Jan 2007 16:25:42 -0500

On 18-Jan-2007, Alexander Barth wrote:

| On my system (Linux), it returns an absolute filename (which I think
| is the correct behavior, or not?). I think this is the problem which
| prevents you to install packages with relative filenames.

The function that is eventually called to perform this task is
file_ops::canonicalize_file_name, which is defined in
liboctave/  Here it is:

  file_ops::canonicalize_file_name (const std::string& name, std::string& msg)
    msg = std::string ();

    std::string retval;


    char *tmp = ::canonicalize_file_name (name.c_str ());

    if (tmp)
        retval = tmp;
        ::free (tmp);

  #elif defined (HAVE_RESOLVEPATH)

  #if !defined (errno)
  extern int errno;

  #if !defined (__set_errno)
  # define __set_errno(Val) errno = (Val)

    if (name.empty ())
        __set_errno (ENOENT);
        return retval;

    // All known hosts with resolvepath (e.g. Solaris 7) don't turn
    // relative names into absolute ones, so prepend the working
    // directory if the path is not absolute.

    std::string absolute_name
      = octave_env::make_absolute (name, octave_env::getcwd ());

    size_t resolved_size = absolute_name.length ();

    while (true)
        resolved_size = 2 * resolved_size + 1;

        OCTAVE_LOCAL_BUFFER (char, resolved, resolved_size);

        int resolved_len
          = ::resolvepath (absolute_name.c_str (), resolved, resolved_size);

        if (resolved_len < 0)

        if (resolved_len < resolved_size)
            retval = resolved;

  #elif defined (__WIN32__)

    int n = 1024;

    std::string win_path (n, '\0');

    while (true)
        int status = GetFullPathName (name.c_str (), n, &win_path[0], NULL);

        if (status == 0)
        else if (status < n)
            win_path.resize (status);
            retval = win_path;
            n *= 2;
            win_path.resize (n);


    // FIXME -- provide replacement here...
    retval = name;


    if (retval.empty ())
        using namespace std;
        msg = ::strerror (errno);

    return retval;

I suspect you are ending up in the FIXME part.  So I think if people
want this to work, someone needs to write the code for systems that
are note Windows and that also are missing either the
canonicalize_file_name or resolvepath functions.

I see that an implementation of canonicalize_file_name is in gnulib,
so that might be a good place to start.  I see that it also uses
resolvepath if that is available, so we could do away with a good
portion of our implementation above if we used the code from gnulib.

There are other functions in gnulib that would probably be useful for
Octave, so coming up with a clean way to use gnulib sources in Octave
would be useful.



reply via email to

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