Thread View: fj.lang.c
2 messages
2 total messages
Started by Toshiya Andoh
Fri, 27 Mar 1998 00:00
dirent.d_name
Author: Toshiya Andoh
Date: Fri, 27 Mar 1998 00:00
Date: Fri, 27 Mar 1998 00:00
49 lines
1934 bytes
1934 bytes
安藤@富士通NCSと申します。
ディレクトリ内のサブディレクトリ名を取得するためのプログラムを、
solaris 1.x系で作成し、それをsolaris 2.x系でも動かそうとしました。
ところが、readdirで得られる、dirent内のファイル名の情報が頭2byte
削られて表示されました。
# 実際には、ファイル名が2byteずれて格納されていました。
これは、OSのバグでしょうか、
それともコンパイルの仕方(オプションは指定してません)が悪いのでしょうか。
回答よろしくお願いします。
うまくいった環境:
SunOS 4.1.3-JLE1.1.3 + SUN SPARC C Compiler
SunOS 4.1.4-JL + SUN SPARC C Compiler
solaris 2.4 + SUN SPARC C Compiler
solaris 2.4 + gcc
solaris 2.5 + gcc
solaris 2.6 + gcc
うまくいかなかった環境:
solaris 2.5 + SUN SPARC C Compiler
solaris 2.6 + SUN SPARC C Compiler
------------------------------------------------------
#include <stdio.h>
#include <dirent.h>
main()
{
DIR *dirp;
struct dirent *direntp;
dirp = opendir( "." );
while ( (direntp = readdir( dirp )) != NULL )
(void)printf( "%s\n", direntp->d_name );
(void)closedir( dirp );
return (0);
}
--
富士通名古屋通信システム(株) システムエンジニアリング部
〇氏名 :安藤 俊也
〇TEL :052-952-8914
〇E-mail:andou@ncs.ts.fujitsu.co.jp
Re: dirent.d_name
Author: HASHIMOTO, Tsuyoshi
Date: Fri, 27 Mar 1998 00:00
Date: Fri, 27 Mar 1998 00:00
39 lines
2430 bytes
2430 bytes
$B66K\!J$D!K!wIY;NDL$G$9!%(B In article <NEWTNews.890963246.4368.andou@andou.ncs.ts.fujitsu.co.jp> Toshiya Andoh <andou@ncs.ts.fujitsu.co.jp> writes: >$B%G%#%l%/%H%jFb$N%5%V%G%#%l%/%H%jL>$r<hF@$9$k$?$a$N%W%m%0%i%`$r!"(B >solaris 1.x$B7O$G:n@.$7!"$=$l$r(Bsolaris 2.x$B7O$G$bF0$+$=$&$H$7$^$7$?!#(B >$B$H$3$m$,!"(Breaddir$B$GF@$i$l$k!"(Bdirent$BFb$N%U%!%$%kL>$N>pJs$,F,(B2byte >$B:o$i$l$FI=<($5$l$^$7$?!#(B ># $B<B:]$K$O!"%U%!%$%kL>$,(B2byte$B$:$l$F3JG<$5$l$F$$$^$7$?!#(B >$B$&$^$/$$$+$J$+$C$?4D6-(B: >solaris 2.5 + SUN SPARC C Compiler >solaris 2.6 + SUN SPARC C Compiler $BLdBj$N4D6-$G$O!$B?J,(B LD_LIBRARY_PATH $B$J$I$N@_Dj$N4X78(B ($B3NG'J}K!$O(B ldd) $B$G(B Solaris2 FAQ ( http://www.wins.uva.nl/pub/solaris/solaris2/ ) $B$K$b(B $B$"$k2<5-$NLdBj$,5/$-$?$N$G$7$g$&!%(Bman -s3b readdir $B$H(B man -s3c readir $B$N0c$$$rLdBj$N4D6-$G3NG'$7$F2<$5$$!%(B 6.19) Why doesn't readdir work? It chops the first two characters of all filenames. You're probably linking with libucb and didn't read question 6.18. (Readdir in libucb.so wants you to include sys/dir.h, but many SunOS 4.1.x programs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ included <dirent.h>, consequently, you're mixing native <dirent.h> struct ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dirent with libucb readdir(). The symptom of this mixup is that the first two ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ characters of each filename are missing. Make sure you use a native compiler ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ $BOC$NFbMF$+$i!$(B Newsgroups: fj.lang.c,fj.sys.sun Followup-To: fj.sys.sun $B$H$7$^$7$?!%(B -- $B66K\!!9d(B (HASHIMOTO, Tsuyoshi)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads