commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: [io] New enum for file system info?
Date Wed, 15 Nov 2017 20:11:30 GMT
On Wed, Nov 15, 2017 at 12:53 PM, Jan Matèrne (jhm) <apache@materne.de>
wrote:

> s/MAC_OSX_9/MAC_OS_9/
> What about older versions of MacOS?
> UNKNOWN(31,1024) // smallest values for safety
> Are there differences between FAT,FAT32,NTFS,reiserfs,... ?
>

Here you go: https://en.wikipedia.org/wiki/Comparison_of_file_systems

This makes me wonder of the enum name should not be OS name but the FS name
like FAT32.

Gary


>
> Jan
>
>
> > -----Urspr√ľngliche Nachricht-----
> > Von: Gary Gregory [mailto:garydgregory@gmail.com]
> > Gesendet: Mittwoch, 15. November 2017 18:34
> > An: Commons Developers List
> > Betreff: Re: [io] New enum for file system info?
> >
> > On Wed, Nov 15, 2017 at 10:30 AM, Gary Gregory <garydgregory@gmail.com>
> > wrote:
> >
> > > I find myself writing and using non-OO code around things like:
> > >
> > >     private final int MAX_FILE_NAME_LENGTH_WINDOWS = 255;
> > >     private final int MAX_FILE_NAME_LENGTH_LINUX = 255;
> > >     private final int MAX_FILE_NAME_LENGTH_MAC = 255;
> > >     private final int MAX_FILE_NAME_LENGTH_MAC_OS9 = 31;
> > >
> > >     private final int MAX_FILE_PATH_LENGTH_WINDOWS = 32000;
> > >     private final int MAX_FILE_PATH_LENGTH_LINUX = 4096;
> > >     private final int MAX_FILE_PATH_LENGTH_MAC = 1024;
> > >
> > > But that is not even right for older Macs which limits file names to
> > > 31 chars.
> > >
> > > I was thinking of creating a new enum:
> > >
> > > package org.apache.commons.io;
> > >
> > > public enum FileSystem {
> > >
> > >     LINUX(255, 4096),
> > >     MAC_OSX(255, 1024),
> > >     MAC_OSX_9(31, 1024),
> > >     WINDOWS(255, 32000);
> > >
> > >     private final long maxFileLength;
> > >     private final long maxPathLength;
> > >
> > >     private FileSystem(long maxFileLength, long maxPathLength) {
> > >         this.maxFileLength = maxFileLength;
> > >         this.maxPathLength = maxPathLength;
> > >     }
> > >
> > >     public long getMaxFileLength() {
> > >         return maxFileLength;
> > >     }
> > >
> > >     public long getMaxPathLength() {
> > >         return maxPathLength;
> > >     }
> > >
> > >     public boolean isIllegalFileName(char ch) {
> > >         ...
> > >     }
> > >
> > >     public String toLegalFileName(String candidate, char replacement)
> > {
> > >         ...
> > >     }
> > >
> > > }
> > >
> > > I would also move the new method from https://issues.apache.org/
> > > jira/browse/IO-555 there and rename it "isIllegalFileName(char)"
> > >
> > > Thoughts?
> > >
> >
> > The enum would obviously need a "public static FileSystem getCurrent()"
> > method.
> >
> > Gary
> >
> >
> > >
> > > Gary
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message