#includeint main() { BEntry entry("/home/user/text.txt"); if (entry.Exists() && entry.IsFile()) { printf("The file exists!\n"); } return 0; }
#includeIn this example, we create a BDirectory object for a directory at /home/user/docs. We then loop through all the entries in the directory using the GetNextEntry() method until there are no more entries. For each entry, we check if it's a file using the IsFile() method, and if it is, we print its name using the Name() method. Package/Library: Libbeint main() { BDirectory dir("/home/user/docs"); while (dir.GetNextEntry(&entry) == B_OK) { if (entry.IsFile()) { printf("%s\n", entry.Name()); } } return 0; }