Monday, November 08, 2010 at 12:00 AM.
river2Suite.podcasts.cleanFilename
on cleanFilename (fname) {
<<Changes
<<3/28/08; 11:12:30 AM by DW
<<If a file name is too long, don't drop the extension, because without the extension the OS won't know what to do with the file.
<<9/19/05; 5:45:19 PM by DW
<<Legal characters for DOS file names include the following:
<<Upper case letters A-Z
<<Numbers 0-9
<<Space (though trailing spaces are considered to be padding and not a part of the file name)
<<! # $ % & ( ) - @ ^ _ ` { } ~ '
<<Values 128-255
if system.environment.isWindows {
local (i, ch, fllegal, s="");
for i = 1 to sizeof (fname) {
ch = fname [i];
fllegal = true;
if not string.isalpha (ch) {
if not string.isnumeric (ch) {
if (number (char (ch)) < 128) {
if not ({' ', '!', '#', '%', '.', ',', '&', '(', ')', '-', '@', '_', '`', '{', '}', '~', "'"} contains ch) {
fllegal = false}}}};
if fllegal {
s = s + ch}};
return (s)}
else {
fname = string.replaceall (fname, ":", "-");
fname = string.replaceall (fname, "!", "");
fname = string.replaceall (fname, "|", "");
if sizeof (fname) >= 32 { //too long!
if fname contains "." {
local (ext = "." + string.lastfield (fname, "."));
fname = string.mid (fname, 1, 31 - sizeof (ext)) + ext} //3/28/08 by DW
else {
fname = string.mid (fname, 1, 31)}};
return (fname)}};
bundle { //test code
dialog.alert (cleanFilename ("030708-clinton-calla.source.prod_affiliate.91.mp3"))}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.