What are the rules for file extensions on Windows and Unix?

I am currently using File :: Basename fileparse to highlight the file directory, base file name and extension using something like this:

my($myfile_name,$mydirectory, $file_extension) = fileparse($$rhash_params{'storage_full_path_location'},'\..{1,4}');

      

But see if there is a variation where you can actually provide an array of suffixes to a function, the array will contain all known file extensions.

So I am trying to find a safe way to do this as I saw that I have some weird filenames to handle, i.e. file.0f1.htm etc.

Question:

  1. Is there a list of the most commonly used extensions for Windows and Unix systems? But in my case it is mostly for Windows.
  2. And is it safe to assume that all filenames in Windows must have a three-letter extension?

And if there's an even better way to do it, share.

Thank.

Update:

So obviously I have to be drunk to forget about those other extensions. :) So I updated the current regex to allow it from 1-4chars.

In this case, how do I change the regex string to match it? Or is it even better to consider looking for everything commonly used to extend from Google and putting them in an array to be passed to the function instead? My users are usually either students or teachers.

+1


source to share


2 answers


1

... Is there a list of commonly used extensions for Windows and Unix systems? But in my case it is mostly for Windows.

Yes, loads all over the internet: http://www.google.com/search?q=common+file+extensions



2

... And is it safe to assume that all filenames in Windows must have an extension ending with three letters characters?

No, it is quite possible to use '.c'

, '.java'

etc. on Windows.

+3


source


There are several errors in the code:



  • files must not have extensions. For example, most binary executables on Unix / Linux / ... do not have an extension at all. They are just calls "bash", "wget", "sed", "Xorg", ... Extensions
  • do not have to contain three characters as @Alnitak already told you: ".c", ".java", ".mpeg", ".jpeg", ".html" are all fine and quite widespread - extension distribution
  • shortening on the last "." probably stored, but can still work with files without extensions or with multiple (or multipart) extensions such as ".tar.gz", "tar.bz2", which are quite common in Unix / Linux /...- World
+1


source







All Articles