Redandwhite
Redandwhite

Reputation: 2549

Check if a file is a system / OS file?

In Java, is there a way to check if a given File object is a protected system file?

Some examples of File objects which I'd expect to be classified as protected:

Windows

C:\WINDOWS\
C:\WINDOWS\explorer.exe

Others

~/Library/
/Library/
/var/
/sys/
/bin/

etc...

Upvotes: 3

Views: 373

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533790

What is a system file is highly system dependant. Windows Explorer has a notion of system directories which it tries to hide from users. On Linux/Unix you could look at who owns the directories.

Generally speaking, you don't need to know this as the file permissions controls whether you can read/write/execute a file.

How will you use this information, in a way that permissions won't do for you?

Upvotes: 1

Related Questions