[Vala] FileInfo.get_file_type()




Hi,

Can anyone tell me why the following program always returns UNKNOWN for the file type?

public class DirList
{
    public static int main (string[] args)
    {
        try {
            File dir = File.new_for_path (".");
var enumerator = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME, 0, null);

            FileInfo file_info;
            while ((file_info = enumerator.next_file (null)) != null ) {
                FileType ft = file_info.get_file_type ();
                switch (ft)
                {
                    case FileType.UNKNOWN:
                    stdout.printf( "UNKNOWN: %s\n", file_info.get_name() );
                    break;

                    case FileType.REGULAR:
                    stdout.printf( "REGULAR: %s\n", file_info.get_name() );
                    break;

                    case FileType.DIRECTORY:
stdout.printf( "DIRECTORY: %s\n", file_info.get_name() );
                    break;

                    case FileType.SYMBOLIC_LINK:
stdout.printf( "SYMBOLIC_LINK: %s\n", file_info.get_name() );
                    break;

                    case FileType.SPECIAL:
                    stdout.printf( "SPECIAL: %s\n", file_info.get_name() );
                    break;

                    case FileType.SHORTCUT:
stdout.printf( "SHORTCUT: %s\n", file_info.get_name() );
                    break;

                    case FileType.MOUNTABLE:
stdout.printf( "MOUNTABLE: %s\n", file_info.get_name() );
                    break;

                    default:
stdout.printf( "UNIDENTIFIED: %s\n", file_info.get_name() );
                    break;
                }
            }
        } catch (Error e) {
            stderr.printf ("Error: %s\n", e.message);
            return 1;
        }

    // Return from main method
    return 0;
    }
}

Results:

>:~/Developer/Vala$ ./dirlist-test
UNKNOWN: Hello World
UNKNOWN: gtk-hello.vala
UNKNOWN: async-list-directory.vala
UNKNOWN: gtk-hello
UNKNOWN: empty-folders.vala
UNKNOWN: empty-folders
UNKNOWN: dirlist-test.vala
UNKNOWN: dirlist-test
UNKNOWN: async-list-directory
UNKNOWN: Projects
UNKNOWN: Vapi

These files in the results are directories:

Hello World
Projects
Vapi

Thanks for any help you can give me.
P.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]