[vox-tech] using windows pathnames in cygwin

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Wed Feb 1 09:35:33 PST 2006


I see two issues: use of absolute paths, and a place for the gvim swapfile.

The swapfile error would probably not affect your ability to edit files
if you were using relative pathnames or the correct absolute pathnames.

More below.

Peter Jay Salzman wrote:

[..]

> I tried calling the bat file by name:
> 
>    $ /cygdrive/c/WINDOWS/gvim.bat /cygdrive/c/boot.ini

The "/cygdrive/c" notation is a software fiction that only cygwin programs
understand.  Giving a non-cygwin program (such as your gvim.exe) an argument
that uses this fiction won't work.

If at all possible, specify filenames at or below your current directory
level using relative path names.  I find that working on files in the
current working directory is very easy and intuitive in all cases.

If you must use absolute paths, then arguments to non-cygwin programs
MUST be composed using the Windows directory structure... so your
commandline should be:

   $ /cygdrive/c/WINDOWS/gvim.bat /boot.ini

Note that the path used to find the batch file is interpreted by cygwin, so
it must use the /cygdrive/c/ fiction, and the argument is interpreted by
gvim.exe, so it can get away with using the implied "current drive" (C:)
and forward slashes are interchangeable with backslashes in filenames,
but it has to start at the root of the Windows drive.

> and got the same result:
> 
>    Unable to open swap file for \cygdrive\c\boot.ini
> 
> and gvim left me editing an empty file.  I have a new job which leaves me
> zilch free time, plus I have a two hour commute each way (ugh!) so I don't
> have much time for experimentation these days.  I don't suppose you have a
> magic pill for this?  :)

The vim documentation associates this with failure to set the
"directory" option to a valid value.  It appears
that you can create a C:\TMP directory if you normally
work on drive C, or change the directory option with the
"set" command to include the current directory or a "TMP"
directory that you can write to.

Because the vim website was running extremely slow this morning,
I am including the docs for the vim directory option for
your convenience:
(from http://www.vim.org/htmldoc/options.html#'directory')

---------------------------------------------------------
                                 *'directory'* *'dir'*
'directory' 'dir'       string	(default for Amiga: ".,t:",
                                  for MS-DOS and Win32: ".,c:\tmp,c:\temp"
                                  for Unix: ".,~/tmp,/var/tmp,/tmp")
                         global
         List of directory names for the swap file, separated with commas.
         - The swap file will be created in the first directory where this is
	  possible.
         - Empty means that no swap file will be used (recovery is
           impossible!).
         - A directory "." means to put the swap file in the same directory
           as the edited file.  On Unix, a dot is prepended to the file
           name, so it doesn't show in a directory listing.  On
           MS-Windows the "hidden" attribute is set and a dot
           prepended if possible.
         - A directory starting with "./" (or ".\" for MS-DOS et.al.)
           means to put the swap file relative to where the edited file
           is.  The leading "." is replaced with the path name of the
           edited file.
	- For Unix and Win32, if a directory ends in two path separators,
           the swap file name will be built from the complete path to
           the file with all path separators substituted to percent
           '%' signs.
           This will ensure file name uniqueness in the preserve directory.
         - Spaces after the comma are ignored, other spaces are
           considered part of the directory name.  To have a space at
           the start of a directory name, precede it with a backslash.
         - To include a comma in a directory name precede it with
           a backslash.
         - A directory name may end in an ':' or '/'.
         - Environment variables are expanded |:set_env|.
         - Careful with '\' characters, type one before a space, type two to
           get one in the option (see |option-backslash|), for example:
           :set dir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces
         - For backwards compatibility with Vim version 3.0 a '>' at the
           start of the option is removed.
         Using "." first in the list is recommended.  This means that editing
         the same file twice will result in a warning.  Using "/tmp" on
         Unix is discouraged: When the system crashes you lose the swap file.
         "/var/tmp" is often not cleared when rebooting, thus is a better
         choice than "/tmp".  But it can contain a lot of files, your swap
         files get lost in the crowd.  That is why a "tmp" directory in your
         home directory is tried first.
         The use of |:set+=| and |:set-=| is preferred when adding or
         removing directories from the list.  This avoids problems when a
         future version uses another default.
         This option cannot be set from a |modeline| or in the |sandbox|, for
         security reasons.
         {Vi: directory to put temp file in, defaults to "/tmp"}

-- 
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------


More information about the vox-tech mailing list