Raised This Month: $ Target: $400
 0% 

function for safe filenames?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
sluggo
Member
Join Date: May 2006
Old 10-21-2006 , 23:15   function for safe filenames?
Reply With Quote #1

Hi,
Just wondering if there is a function to create safe filenames?
If i use peoples nicks to create a file they often have "|" or "\" or "/", I have seen somewhere a function for "safe sql-queries" but is there one for filenames?

I have made my own but I don't think it is... well it's probably not that efficient, and I don't know how to check some characters :S

If someone could point me to an "safe filename" function or help me with this one I would be greatefull!
Code:
public myReplaceFileName(string[33]){     replace_all(string,32,":","_")     replace_all(string,32,"/","_")     replace_all(string,32,"\","_") // this one looks different in the compiler (the _ is blue instead of red... something is wrong?     replace_all(string,32,"?","_")     replace_all(string,32,"<","_")     replace_all(string,32,">","_")     replace_all(string,32,"|","_")     replace_all(string,32,"^"","_") // dont know if this works... want to replace " in the filename.     replace_all(string,32,"'","_")     replace_all(string,32,"`","_")     replace_all(string,32,"´","_") //  replace_all(string,32,"^","_") // dont know how to replace ^ }

I know some of the characters ARE valid in filenames but I don't want them in my filenames thats why they are in the function.
sluggo is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:54.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode