473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Function to validate a Unix file name?

Hi,

Can anyone provide a function that can validate if a string would pass
as a valid Unix (specifically Fedora Core 8 Linux) file name? For
example, I'm fairly certain one of the rules is that the file name
cannot contain a "&" character. There are probably a lot of other
rules I don't know about.

Thanks, - Dave
Aug 25 '08 #1
3 2460
laredotornado <la***********@zipmail.comwrites:
Hi,

Can anyone provide a function that can validate if a string would pass
as a valid Unix (specifically Fedora Core 8 Linux) file name? For
example, I'm fairly certain one of the rules is that the file name
cannot contain a "&" character. There are probably a lot of other
rules I don't know about.
A unix file name may not contain a slash "/" or a null
character. There are no other limitations, except that many systems
have a maximum filename* length (255 chars seems to be the limit on
ext3).

* paths may be a lot longer since they can contain many filenames.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Aug 25 '08 #2
laredotornado wrote:
Can anyone provide a function that can validate if a string would pass
as a valid Unix (specifically Fedora Core 8 Linux) file name? *For
example, I'm fairly certain one of the rules is that the file name
cannot contain a "&" character. *There are probably a lot of other
rules I don't know about.
I would play safe and allow alphanumeric + underscore + minus + dot.

--
Bart
Aug 26 '08 #3
Well, as far as I know all characters except '/' (slash) and null are
allowed. Slash is the directory separator and null is end of string in
C implementation.

However, you should care about special use of certain characters in
shells. Like wildcards '*', '?'...

Also care for character set conversion. JavaScript uses Unicode but
Unix file names usually only use some ISO 8 bit representation which
is different from Unicode representation in many cases.

And regarding implementation of a checking function I recommend a
regular expression.

virtuPIC
--
Airspace V - international hangar flying!
http://www.airspace-v.com/ggadgets for tools & toys
Aug 26 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
0
by: Aaron P Frenger | last post by:
Hello All, I have a very large XML file that I would like to split up into a few smaller files, but still use only one schema. I am using Xerces C++ libraries. My idea is to have one schema...
6
by: Jonny | last post by:
Hi, I'm trying to validate my xml against a xsd but I can't get it to work. Originally, I wanted to validate an xml string but since I didn't get that to work I tried to validate an xml file...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
6
by: D | last post by:
Hello all...I have an issue with one of my java script functions that I'm hoping someone can easily help with. I have a web based application that we use to create/sign up for overtime. When we...
1
by: john.swilting | last post by:
I am not good in Javascript I begin I do not understand why my function does not go I post my code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">...
0
by: truthbajaj | last post by:
Hi, I am using Oracle 9i and Unix on my system and trying to execute a UNIX shell command through external procedure in C. I created a shared lib (libextproc.so) for the following function. ...
7
Haitashi
by: Haitashi | last post by:
I have a form that calls a function using the onClick event in the submit button. I would like this function to return false if the username is taken. The the original function, which I've tested,...
1
by: Beamor | last post by:
function art_menu_xml_parcer($content, $showSubMenus) { $doc = new DOMDocument(); $doc->loadXML($content);//this is the line in question $parent = $doc->documentElement; $elements =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.