473,765 Members | 2,086 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2478
laredotornado <la***********@ zipmail.comwrit es:
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
4964
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 webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
0
1591
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 specified in the main file. At some point in the schema I would add a choice element that would either have a tag that specifies an external file or a tree of tags. Once the main xml file is loaded I would search for any instances where the
6
2754
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 instead. Didn't work either. Actuallty, the xml gets loaded but there are no events raised that says my xml is incorrect! I'm using .NET 2.0 and my code is listed below. ALL help is appreciated! Thanks!
4
2370
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 which I mean here. Just for a moment, let's just take one definition for one of the
6
4309
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 have holidays we require our employees to sign up in 4 hr increments for the times we post. I'm having trouble creating a time slot that ends @ 12am. 12pm and all other hours work fine for start/end times. however 12am causes problems. My actual...
1
1650
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"> <html> <head> <title>contact.html</title> <meta name="generator" content="Bluefish 1.0.7"> <meta name="author" content="swilting">
0
3649
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. int sysrun(char *command) { return system(command); }
7
11083
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, returns the correct info when the "checkUname" button is clicked. However, it always returns false. I want to return false ONLY if the username is taken. Original: $("#checkUname").click(function(){ var datastring=...
1
6471
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 = $parent->childNodes; need help. my site worked fine on my localhost but when i uploaded it to my live server i keep getting this error need help to recode line to match my hosting server. im using php 5 i have attached the common_method file
0
9566
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10153
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9946
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6646
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5272
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3530
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.