如何访问 Cygwin 目录之外的 Windows 目录

如何访问 Cygwin 目录之外的 Windows 目录

在 cygwin 下工作时,是否可以访问 Cygwin 目录之外的 Windows 目录,例如 Windows 的 C:\Program Files\?

http://www.voxforge.org/home/docs/cygwin-cheat-sheet仅提及 C:\cygwin 下的子目录,而不提及其外部的子目录。

谢谢。

答案1

这取决于你的 cygwin 发行版有多旧。请参阅https://stackoverflow.com/questions/1850920/how-to-navigate-to-a-directory-in-c-with-cygwin

基本上,您应该能够执行以下操作之一:

  • cd /cygdrive/c
  • cd c:
  • cd /c

答案2

是否可以访问 Cygwin 目录之外的 Windows 目录?

是的。mount您的驱动器:

$ mount --help
Usage: mount [OPTION] [<win32path> <posixpath>]
       mount -a
       mount <posixpath>

Display information about mounted filesystems, or mount a filesystem

  -a, --all                     mount all filesystems mentioned in fstab
  -c, --change-cygdrive-prefix  change the cygdrive path prefix to <posixpath>
  -f, --force                   force mount, don't warn about missing mount
                                point directories
  -h, --help                    output usage information and exit
  -m, --mount-entries           write fstab entries to replicate mount points
                                and cygdrive prefixes
  -o, --options X[,X...]        specify mount options
  -p, --show-cygdrive-prefix    show user and/or system cygdrive path prefix
  -V, --version                 output version information and exit

Valid options are: acl,auto,binary,bind,cygexec,dos,exec,ihash,noacl,nosuid,notexec,nouser,override,posix=0,posix=1,sparse,text,user

例子:

$ mount
C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin on / type ntfs (binary,auto)
C: on /c type ntfs (binary,posix=0,user,noumount,auto)
E: on /e type vfat (binary,posix=0,user,noumount,auto)
F: on /f type ntfs (binary,posix=0,user,noumount,auto)
$ ls /c
'$Recycle.Bin'  books          'Documents and Settings'  Intel         'Program Files'        SPLASH.000  'System Volume Information'  Users                   Windows
_FS_SWRINFO     Config.Msi     Drivelists                music         'Program Files (x86)'  splash.idx  temp                         'VAIO Sample Contents'
apps            cygwin         games                     pagefile.sys  ProgramData            SPLASH.SYS  test                         VTRoot
AVScanner.ini   Documentation  hiberfil.sys              PerfLogs      projects               sysadmin    Update                       wamp

相关内容