'\" '\" Copyright (c) 1995-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: filename.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: filename.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH filename 3tcl 7.5 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME filename \- Tcl 命令支援的檔名轉換 .BE .SH INTRODUCTION .PP 所有接受檔名作為引數的 Tcl 命令和 C 過程希望檔名是依賴於當前平臺的三種形式之一。在每種平臺上,Tcl 都支援這種平臺上的標準形式的檔名。額外的,在所有平臺上,Tcl 支援一種 Unix 式的語法,提供了一種方便的方式來構造簡單的檔名。但是,打算被移植的指令碼不要假定特定形式的檔名。可移植的指令碼必須使用 \fBfile split\fR 和 \fBfile join\fR 命令來操縱檔名(詳見\fBfile\fR 的手冊條目)。 .SH "路徑型別 PATH TYPES" .PP 基於用來指定檔案的路徑的起點,檔名被組織成三種一般型別: 絕對,相對,相對-卷。絕對名字是完全限定的(qualified),給出的到檔案的路徑相對於一個特定的卷和在這個捲上的根目錄。相對名字是未限定的,給出的到檔案的路徑相對於當前的工作目錄。相對-卷名字是部分限定的,給出的路徑要麼相對在當前捲上的根目錄,要麼相對於在指定捲上的當前目錄。使用 \fBfile pathtype\fR 命令來確定一個給定路徑的型別。 .SH "路徑語法 PATH SYNTAX" .PP 本地名字的規則依賴於在 Tcl 陣列元素 \fBtcl_platform(platform) \fR中報告的值: .TP 10 \fBmac\fR 在 Apple Macintosh 系統上,Tcl 支援兩種形式的路徑名。常規 Mac 式樣的名字使用分號作為路徑分隔符。路徑可以是相對的或絕對的,並且檔名中可以包含除了分號之外的任何字元。一個前導的分號導致路徑的剩餘部分被解釋成相對當前目錄。如果一個路徑包含一個不在開始處的分號,則路徑被解釋成一個絕對路徑。在路徑中任何地方的兩個或多個分號的序列被用做構造相對路徑,這裡的 \fB::\fR 參照當前目錄的父目錄,\fB:::\fR 參照父目錄的父目錄,以此類推。 .RS .PP 除了 Macintosh 式樣的名字,Tcl 還支援 Unix 式名字的一個子集。如果一個路徑不包含分號,則把它按一個 Unix 路徑來解釋。使用斜槓作為路徑分隔符。檔名 \fB\&.\fR 參照當前目錄,而 \fB\&..\fR 參照當前目錄的父目錄。但是,象 \fB/\fR 或 \fB/..\fR的一些名字沒有對映,並被作為 Macintosh 名字解釋。一般的,生成檔名的命令返回 Macintosh 式樣的名字,而接收檔名的命令接受 Macintosh 和 Unix 式樣的兩種名字。 .PP 下列例子展示不同形式的路徑名: .TP 15 \fB:\fR 到當前資料夾(folder)的相對路徑。 .TP 15 \fBMyFile\fR 到在當前資料夾中的叫 \fBMyFile\fR的一個檔案的相對路徑。 .TP 15 \fBMyDisk:MyFile\fR 到在叫 \fBMyDisk \fR的裝置上的一個叫 \fBMyFile\fR 的檔案的絕對路徑。. .TP 15 \fB:MyDir:MyFile\fR 到在當前資料夾中的一個叫 \fBMyDir\fR的資料夾中的一個叫 \fBMyFile\fR 的檔案的相對路徑。 .TP 15 \fB::MyFile\fR 到在當前資料夾的上層資料夾中的一個叫 \fBMyFile\fR 的檔案的相對路徑。 .TP 15 \fB:::MyFile\fR 到在當前資料夾的上兩層資料夾中的一個叫 \fBMyFile\fR 的檔案的相對路徑。 .TP 15 \fB/MyDisk/MyFile\fR 在叫 \fBMyDisk \fR的裝置上的一個叫 \fBMyFile\fR 的檔案的絕對路徑。 .TP 15 \fB\&../MyFile\fR 到在當前資料夾的上層資料夾中的一個叫 \fBMyFile\fR 的檔案的相對路徑。 .RE .TP \fBunix\fR 在 Unix 平臺上,Tcl 使用的路徑名的組成部分由斜槓來分隔。路徑名可以是相對的或絕對的,並且檔名可以包含除斜槓之外的任何字元。檔名 \fB\&.\fR 和 \fB\&..\fR 是特殊的並且分別參照當前目錄和當前目錄的父目錄。多個毗接的(adjacent)的斜槓被解釋為一個單一的分隔符。下列例子展示不同形式的路徑名: .RS .TP 15 \fB/\fR 到根目錄的絕對路徑。 .TP 15 \fB/etc/passwd\fR 到在根目錄中的 \fBetc\fR 目錄中的一個叫 \fBpasswd\fR 的檔案的絕對路徑。 .TP 15 \fB\&.\fR 到當前目錄的相對路徑。 .TP 15 \fBfoo\fR Relative path to the file \fBfoo\fR in the current directory. .TP 15 \fBfoo/bar\fR 到在當前目錄中的一個叫 \fBfoo\fR 的檔案的相對路徑。 .TP 15 \fB\&../foo\fR 到在當前目錄中的目錄 \fBfoo\fR 目錄中的一個叫 \fBbar\fR 的檔案的相對路徑。 .RE .TP \fBwindows\fR 在 Microsoft Windows 平臺上,Tcl 支援相對驅動器和 UNC 式樣的名字兩者。\fB/\fR 和 \fB\e\fR 二者都可用在兩種型別的名字中做分隔符。相對驅動器的名字由可選的驅動器指定符(specifier)和隨後的絕對或相對的路徑組成。UNC 路徑依從 \fB\e\eservername\esharename\epath\efile\fR 的一般形式。在兩種形式中,檔名 \fB.\fR 和 \fB..\fR 是特殊的並且分別參照當前目錄和當前目錄的父目錄。下列例子展示不同形式的路徑名: .RS .TP 15 \fB\&\e\eHost\eshare/file\fR 到在主機 \fBHost \fR上的匯出點 \fBshare\fR 的根目錄中的一個叫 \fBfile\fR 的檔案的絕對 UNC 路徑。 .TP 15 \fBc:foo\fR 到在驅動器 \fBc \fR上的當前目錄中的一個叫 \fBfoo\fR 的檔案的相對卷的路徑。 .TP 15 \fBc:/foo\fR 到在當前捲上的當前目錄中 \fBfoo\fR 目錄中一個叫 \fBbar\fR 的檔案的絕對路徑。 .TP 15 \fBfoo\ebar\fR 到在當前捲上的當前目錄中 \fBfoo\fR 目錄中一個叫 \fBbar\fR 的檔案的相對路徑。 .TP 15 \fB\&\efoo\fR 到在當前卷的根目錄中的一個叫 \fBfoo\fR 的檔案的相對卷的路徑。 .RE .SH "波浪線替換 TILDE SUBSTITUTION" .PP 除了上述檔名規則之外,Tcl 還支援 csh 式樣的波浪線替換。如果一個檔名以一個波浪線開始,則按檔名的第一個元素被給定使用者的主目錄的位置所替換來解釋。如果波浪線之後立即跟隨著一個分隔符,則用 \fB$HOME\fR 環境變數來替換。否則在波浪線和下一個分隔符之間的的字元被接受為一個使用者名稱,它被用來檢索用於替換的使用者的主目錄。 .PP Macintosh 和 Windows 不支援對波浪線跟隨一個使用者名稱的波浪線替換。在這些平臺上,使用波浪線並跟隨一個使用者名稱的嘗試將生成一個錯誤。有一個波浪線而沒有使用者名稱的檔名將象 Unix 一樣使用 \fB$HOME\fR 環境變數來替換。 .SH "移植要點 PORTABILITY ISSUES" .PP 注意所有的檔案系統都是大小寫敏感的,所以指令碼應避免依賴於在檔名中的字元大小寫的程式碼。額外的,在不同裝置上允許的字符集可能不同,所以指令碼指令碼應選擇不包含特殊字元如 \fB<>:"/\e|\fR 的檔名。最安全的方式是隻使用由字母組成的使用者名稱。還有 Windows 3.1 只支援有不多於8個字元的根和不多於3個字元的擴充套件的檔名。 .SH "關鍵字 KEYWORDS" current directory, absolute file name, relative file name, volume-relative file name, portability .SH "參見 SEE ALSO" file(n), glob(n) .SH "[中文版維護人]" .B 寒蟬退士 .SH "[中文版最新更新]" .B 2001/08/28 .SH "《中國 Linux 論壇 man 手冊頁翻譯計劃》:" .BI http://cmpp.linuxforum.net .SH "跋" .br 本頁面中文版由中文 man 手冊頁計劃提供。 .br 中文 man 手冊頁計劃:\fBhttps://github.com/man-pages-zh/manpages-zh\fR