1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Wed Jul 21 22:35:42 1993 by Rik Faith (faith@cs.unc.edu)
24 .\" Modified 18 Mar 1996 by Martin Schulze (joey@infodrom.north.de):
25 .\" Corrected description of getwd().
26 .\" Modified Sat Aug 21 12:32:12 MET 1999 by aeb - applied fix by aj
27 .\" Modified Mon Dec 11 13:32:51 MET 2000 by aeb
28 .\" Modified Thu Apr 22 03:49:15 CEST 2002 by Roger Luethi <rl@hellgate.ch>
30 .\" Japanese Version Copyright (c) 1997 IMAMURA Nobutaka
31 .\" all rights reserved.
32 .\" Translated Fri Feb 14 12:40:22 JST 1997
33 .\" by IMAMURA Nobutaka <imamura@spp.hpc.fujitsu.co.jp>
34 .\" Modified Thu Dec 8 05:08:44 JST 1999
35 .\" by Kentaro Shirakata <argrath@yo.rim.or.jp>
36 .\" Modified Sun Mar 12 21:08:44 JST 2000
37 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
38 .\" Updated 2001-01-29 by Kentaro Shirakata <argrath@ub32.org>
39 .\" Updated 2002-03-23 by Kentaro Shirakata <argrath@ub32.org>
40 .\" Updated 2002-10-17 by Kentaro Shirakata <argrath@ub32.org>
41 .\" Updated 2007-01-01 by Kentaro Shirakata <argrath@ub32.org>
42 .\" Updated 2008-08-21, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.07
44 .\" WORD: current working directory ¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê
45 .\" WORD: LEGACY ¡Ö²áµî¤Î̾»Ä(LEGACY)¡×
47 .TH GETCWD 3 2009-03-31 "GNU" "Linux Programmer's Manual"
49 getcwd, getwd, get_current_dir_name \- ¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê̾¤Î¼èÆÀ
52 .B #include <unistd.h>
54 .BI "char *getcwd(char *" buf ", size_t " size );
56 .BI "char *getwd(char *" buf );
58 .B "char *get_current_dir_name(void);"
62 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
63 .RB ( feature_test_macros (7)
68 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
70 .BR get_current_dir_name ():
73 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤Î
74 ÀäÂХѥ¹Ì¾ (absolute pathname) ¤¬Æþ¤Ã¤¿Ê¸»úÎó¤òÊÖ¤¹¡£
75 ÊÖ¤µ¤ì¤ëʸ»úÎó¤Ï NULL ¤Ç½ªÃ¼¤µ¤ì¤ë¡£
76 ¥Ñ¥¹Ì¾¤Ï´Ø¿ô¤Î·ë²Ì¤È¤·¤ÆÊÖ¤µ¤ì¡¢°ú¿ô
83 ´Ø¿ô¤Ï¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤ÎÀäÂХѥ¹Ì¾¤ò
87 ŤÎÇÛÎó¤Ë¥³¥Ô¡¼¤¹¤ë¡£
89 ½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤â´Þ¤á¤¿¡¢¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤Î
92 ¥Ð¥¤¥È¤òĶ¤¨¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢ÊÖ¤êÃͤȤ·¤Æ NULL ¤¬ÊÖ¤ê
97 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¤³¤Î¥¨¥é¡¼¤ò¥Á¥§¥Ã¥¯¤·¡¢
98 ɬÍפ˱þ¤¸¤Æ¤è¤êŤ¤¥Ð¥Ã¥Õ¥¡¤òÍÑ°Õ¤¹¤Ù¤¤Ç¤¢¤ë¡£
100 POSIX.1-2001 ɸ½à¤Î³ÈÄ¥¤È¤·¤Æ¡¢
101 Linux (libc4, libc5, glibc) ¤Ç¤Ï
107 ¤òÍѤ¤¤ÆưŪ¤Ë³ä¤êÅö¤Æ¤ë¡£
110 ¤¬ 0 ¤Î¾ì¹ç¤ò½ü¤¡¢¥Ð¥Ã¥Õ¥¡¤ÎŤµ¤Ï
114 ¤¬ 0 ¤Î¾ì¹ç¤Ë¤ÏɬÍפÊÂ礤µ¤¬³ÎÊݤµ¤ì¤ë¡£
115 ¸Æ¤Ó½Ð¤·Â¦¤Ç¡¢ÊÖ¤µ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤ò
119 .BR get_current_dir_name ()
120 ¤Ï¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤ÎÀäÂХѥ¹Ì¾¤ò¼ý¤á¤ë¤Î¤Ë
125 ¤¬ÀßÄꤵ¤ì¤Æ¤ª¤ê¤½¤ÎÃͤ¬Àµ¤·¤±¤ì¤Ð¡¢¤½¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë¡£
126 ¸Æ¤Ó½Ð¤·Â¦¤Ç¡¢ÊÖ¤µ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤ò
133 ¤Ë¤è¤ë¥á¥â¥ê³ÍÆÀ¤ò°ìÀڹԤʤï¤Ê¤¤¡£
137 ¥Ð¥¤¥È¤ÎŤµ¤ò»ý¤ÄÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ëɬÍפ¬¤¢¤ë¡£
138 ½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤â´Þ¤á¤¿¡¢¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤Î
141 ¥Ð¥¤¥È¤òĶ¤¨¤Æ¤¤¤ë¾ì¹ç¡¢
147 (¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¡¢
149 ¤Ïɬ¤º¤·¤â¥³¥ó¥Ñ¥¤¥ë»þ¤Ë·è¤Þ¤ëÄê¿ô¤Ç¤Ï¤Ê¤¤ÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
150 ¤Þ¤¿¡¢¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë°Í¸¤¹¤ë¾ì¹ç¤â¤¢¤ë¡£
153 °Ü¿¢À¤È¥»¥¥å¥ê¥Æ¥£¾å¤ÎÍýͳ¤«¤é¡¢
155 ¤ÎÍøÍѤϿ侩¤µ¤ì¤Ê¤¤¡£
157 À®¸ù¤¹¤ë¤È¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤ÎÀäÂХѥ¹Ì¾
158 ¤¬Æþ¤Ã¤¿Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
166 ¼ºÇÔ¤·¤¿¾ì¹ç¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï NULL ¤òÊÖ¤·¡¢
168 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
170 ¤¬»Ø¤¹ÇÛÎó¤ÎÆâÍƤÏ̤ÄêµÁ¤Ç¤¢¤ë¡£
174 ¥Õ¥¡¥¤¥ë̾¤Î¹½À®Í×ÁǤËÂФ¹¤ëÆɤ߹þ¤ß¤¢¤ë¤¤¤Ï¸¡º÷¤Î¸¢¸Â¤¬¤Ê¤¤¡£
178 ¤¬ÉÔÀµ¤Ê¥¢¥É¥ì¥¹¤ò»Ø¤·¤Æ¤¤¤ë¡£
184 °ú¿ô¤¬ NULL ¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¤¡£
193 ÀäÂХѥ¹Ì¾¤¬Æþ¤Ã¤¿ NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤ÎŤµ¤¬
198 ¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤¬ºï½ü¤µ¤ì¤Æ¤¤¤ë¡£
202 °ú¿ô¤ÎÃͤ¬¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤ÎÀäÂХѥ¹Ì¾¤ÎŤµ¤è¤ê¾®¤µ¤¤¡£
203 Ťµ¤Ë¤Ïʸ»úÎó¤Î½ªÃ¼¥Ð¥¤¥È¤â´Þ¤Þ¤ì¤ë¡£
204 ¤è¤êÂ礤¤ÇÛÎó¤ò³ÎÊݤ·¤Æ¤â¤¦°ìÅټ¹Ԥ¹¤ëɬÍפ¬¤¢¤ë¡£
207 ¤Ï POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
212 ¤ÎÆ°ºî¤òµ¬Äꤷ¤Ê¤¤¤Þ¤Þ¤È¤·¤Æ¤¤¤ë¡£
215 ¤Ï POSIX.1-2001 ¤Ë¸ºß¤·¤Æ¤¤¤ë¤¬¡¢¡Ö²áµî¤Î̾»Ä(LEGACY)¡×¤È¤µ¤ì¤Æ¤¤¤ë¡£
218 ¤Î»ÅÍͤ¬ºï½ü¤µ¤ì¤Æ¤¤¤ë¡£
224 ¤Ë´Ø¤¹¤ë¥¨¥é¡¼¤òÄêµÁ¤·¤Æ¤¤¤Ê¤¤¡£
226 .BR get_current_dir_name ()
229 Linux ¤Ç¤Ï (2.1.92 °Ê¹ß)¡¢
231 ¤Ï¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ç¤¢¤ë¡£
235 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤â proc ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤â¤Ê¤¤¾ì¹ç¡¢
236 °ìÈÌŪ¤Ê¼ÂÁõ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
237 ¤³¤Î¾ì¹ç¤Ë¤ª¤¤¤Æ¤Î¤ß¡¢(Linux ¤Ç¤Ï) ¤³¤Î´Ø¿ô¤Ï
239 ¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ¤¬¤¢¤ë¡£
241 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¤·¤Ð¤·¤Ð¥«¥ì¥ó¥È¥ï¡¼¥¥ó¥°¥Ç¥£¥ì¥¯¥È¥ê¤Î°ÌÃÖ¤òÊݸ¤·¡¢
242 ¸å¤ÇÌá¤Ã¤Æ¤¯¤ë¤¿¤á¤ËÍøÍѤµ¤ì¤ë¡£
243 ̤»ÈÍѤΥե¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬½½Ê¬¤¢¤ë¾ì¹ç¤Ï¡¢
244 ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê (".") ¤ò³«¤¤¤Æ
246 ¤ò¸Æ¤Ó½Ð¤¹¤Û¤¦¤¬ÉáÄ̤Ϲ⮤ǿ®ÍêÀ¤¬¤¢¤ë¡£
247 ÆÃ¤Ë Linux °Ê³°¤Î¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¤Î¾ì¹ç¤Ï¤½¤¦¤Ç¤¢¤ë¡£