简体   繁体   中英

readdir() showing non visible files

I am using readdir() in Ubuntu to display files and directories. The weird thing is readdir() displays some files starting with "dot", and some that end at ~ . But these files are not in my specified directory.

What are these files?

I was wondering when reading names of files, will these weird files will also be mentioned by d_name or not?

在此处输入图片说明

Regards

readdir reads all files present within the folder, while ls only list non-hidden files. Try to list your files with ls -a , and you will see those files.

By convention, files whose names start with a dot are hidden in Unix-like operating systems (see here ).

You can of course check for the dot at the beginning of the filenames produced by readdir, and simply not return/output those.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM