Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C61E8200D3E for ; Thu, 16 Nov 2017 13:56:04 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C4992160BF4; Thu, 16 Nov 2017 12:56:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1C327160BE5 for ; Thu, 16 Nov 2017 13:56:03 +0100 (CET) Received: (qmail 86616 invoked by uid 500); 16 Nov 2017 12:56:03 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 86605 invoked by uid 99); 16 Nov 2017 12:56:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Nov 2017 12:56:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 4AEAC1A09C3 for ; Thu, 16 Nov 2017 12:56:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id jnn8FMF5nS4t for ; Thu, 16 Nov 2017 12:56:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 1DEA65F298 for ; Thu, 16 Nov 2017 12:56:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A1C67E0662 for ; Thu, 16 Nov 2017 12:56:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 5D9C423F05 for ; Thu, 16 Nov 2017 12:56:00 +0000 (UTC) Date: Thu, 16 Nov 2017 12:56:00 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (IO-555) Add a FileSystem enum to provide legal file names MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 16 Nov 2017 12:56:05 -0000 [ https://issues.apache.org/jira/browse/IO-555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16255248#comment-16255248 ] Sebb commented on IO-555: ------------------------- As per Matt's comment on the dev list, the code is not about which OS is in use, but which file system. A single OS may have multiple file systems of different types. So {{getCurrent()}} does not really make sense; the choice of enum needs to be done differently. Also one cannot use System.out in a library routine. Note that Windows treats some names specially, for example CON, NUL, PRN. These should probably also be rejected. Note that it might well be as cheap to use CharSequence instead of String for toLegalFileName(). This is because String.toCharArray has to create a copy of the String contents as well as allocating a new char[] array. > Add a FileSystem enum to provide legal file names > ------------------------------------------------- > > Key: IO-555 > URL: https://issues.apache.org/jira/browse/IO-555 > Project: Commons IO > Issue Type: Improvement > Reporter: Gary Gregory > Assignee: Gary Gregory > Fix For: 2.7 > > > Add {{org.apache.commons.io.FilenameUtils.isIllegalWindowsFileName(char)}}. > {code:java} > /** > * Checks whether the given character is illegal in a Windows file names. > *

> * The illegal character are: > *

> *
    > *
  • < (less than
  • > *
  • > (greater than
  • > *
  • : (colon
  • > *
  • " (double quote
  • > *
  • / (forward slash
  • > *
  • \ (backslash
  • > *
  • | (vertical bar or pipe
  • > *
  • ? (question mark
  • > *
  • * (asterisk
  • > *
  • ASCII NUL (0)
  • > *
  • Integer characters 1 through 31
  • > *
  • There may be other characters that the file name does not allow. Please see > * Naming Files, Paths, > * and Namespaces
  • > *
> * > * @see Naming Files, > * Paths, and Namespaces > * @param c > * the character to check > * @return whether the give character is legal > * @since 2.7 > */ > {code} > I use this method as a building block to create file names based on Strings from other sources. > A further contribution could be: {{String toLegalWindowsFileName(String input, char replacementChar)}} -- This message was sent by Atlassian JIRA (v6.4.14#64029)