Reply to Re: Regular expression for check that an entered filename is valid

Your name:

Reply:


Posted by Toby A Inkster on 12/19/07 15:42

Captain Paralytic wrote:

> How do you define a valid filename?

Good question. As far as I know, for Linux and most UNIXy OSes it's this:

#[^/]#

i.e. any string that doesn't contain a slash is a valid filename. (Because
of course, the slash must be a directory separator.) Any other character
is valid in a file name -- asterisks, question marks, colons, tabs, line
feeds, whatever. Names "." and ".." are technically allowed, but they
always already exist.

It does depend on the filesystem though. Linux supports dozens of
different filesystems and some of those will limit you further.

Windows is a more fussy. As well as slashes, it doesn't allow colons,
backslashes, asterisks, question marks, whitespace other than the space
character itself, less-than and greater-than signs, double quotes and the
pipe symbol. There are also a small number of reserved file names that
cannot be created, such as "CON", "PRN", "CLOCK$" and "LPT1" -- these
special filenames were used to represent various hardware devices in DOS.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 12 days, 2:00.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация