"P Kishor" wrote...
> On Wed, Feb 11, 2009 at 2:00 PM, jose isaias cabrera > <cabr...@wrc.xerox.com> wrote: >> >> >> "P Kishor" wrote... >> >> >>> On Wed, Feb 11, 2009 at 1:48 PM, jose isaias cabrera >>> <cabr...@wrc.xerox.com> wrote: >>>> >>>> Greetings and salutations... >>>> >>>> I am having a problem with an specific UPDATE. One of the functions of >>>> my >>>> program is to capture all of the files in a directory so that one can >>>> search >>>> on a file name and find out where that file is quickly. This is >>>> working >>>> perfectly, until there is a file that has a single quote (') in its >>>> name. >>>> Say a directory has these three files: >>>> >>>> 1. filename0.txt >>>> 2. filename1.txt >>>> 3. filename'3.txt >>>> 4. filename4.txt >>>> >>>> my update string is this, >>>> >>>> BEGIN; >>>> >>>> UPDATE LSOpenProjects SET >>>> Xtra0 = '', >>>> ... some other settings working ok ... >>>> Xtra3 = ' >>>> filename0.txt >>>> filename1.txt >>>> filename''3.txt >>>> filename4.txt >>>> ', >>>> Xtra4 = '', >>>> Xtra5 = '', >>>> Xtra6 = '', >>>> Xtra7 = '', >>>> Xtra8 = '0.00', >>>> Xtra9 = '', >>>> XtraA = '', >>>> XtraB = '', >>>> XtraC = '', >>>> XtraD = '', >>>> XtraE = '', >>>> XtraF = '' WHERE id = 3487; >>>> COMMIT; >>>> >>>> The column in question is Xtra3. If I rename that file to NOT contain >>>> the >>>> single quote, the UPDATE works. Also, I add a newline (\n) to the >>>> beginning >>>> of the first filename and a new line after every filename. >>>> >>> >>> >>> works fine for me... see below >>> >>> sqlite> CREATE TABLE foo (a, b); >>> sqlite> INSERT INTO foo VALUES (1, ' >>> ...> filename0.txt >>> ...> filename1.txt >>> ...> filename''3.txt >>> ...> filename4.txt >>> ...> '); >>> sqlite> SELECT * FROM foo; >>> 1| >>> filename0.txt >>> filename1.txt >>> filename'3.txt >>> filename4.txt >>> >>> sqlite> UPDATE foo SET b = ' >>> ...> blah.txt >>> ...> gorp.tx >>> ...> messed''up.txt >>> ...> whoa.txt >>> ...> ' WHERE a = 1; >>> sqlite> SELECT * FROM foo; >>> 1| >>> blah.txt >>> gorp.tx >>> messed'up.txt >>> whoa.txt >>> >> >> Yes, I know. It works for me too when I do it by hand. The problem is >> when >> I read the files from the system... Hmmmm... Let me try something... >> > > > care to elaborate on "read files from the system" bit? You didn't > provide that information first time. How are you "reading" files from > the system? I am using D, and the statement to get all the files from a directory and subdirectories is, char[][] dfiles = std.file.listdir(dir,"*"); this will return an array of char[] that will contain all of the files in the directory from. I then do a foreach and create a string and return that string. Here is the function... char[] GetListOfAllFilesInDir(char[] dir) { info.text = "Getting list of files in directory..."; char[][] dfiles = std.file.listdir(dir,"*"); char[] s = "\n"; foreach (char[] f; dfiles) { char[] fn = std.path.getBaseName(f); if (fn[0 .. 1] == ".") { if (std.file.exists(f)) std.file.remove(f); continue; } if (fn[$ - 4 .. $] == ".bak" || fn[$ - 4 .. $] == ".bk1" || fn[$ - 4 .. $] == ".bk2") { if (std.file.exists(f)) std.file.remove(f); continue; } else if(std.string.find(fn,".backup.fm") > 0 || std.string.find(fn,".backup.book") > 0) { if (fn[$ - 12 .. $] == ".backup.book" || fn[$ - 10 .. $] == ".backup.fm") { if (std.file.exists(f)) std.file.remove(f); continue; } } else if(std.string.find(fn,".rtf.backup") > 0) { if (fn[$ - 11 .. $] == ".rtf.backup") { if (std.file.exists(f)) std.file.remove(f); continue; } } else if (std.string.tolower(std.path.getExt(f)) == "msg") { char[] str0 = r"\d+T_"; if (RegExp(str0).find(fn) == 0) // if filename starts with 1123232343434T_ { // No need to tag it with time. Already has been tagged... } else { char[] saveF = f; char[] nf0 = std.string.toString(std.date.getUTCtime()) ~ "T_" ~ fn; char[] dn0 = std.path.getDirName(f); // Parent directory dn0 = dn0 ~ r"\" ~ nf0; //msgBox("1. " ~ saveF ~ "\n2. " ~ dn0,"Testing..."); std.file.rename(saveF,dn0); fn = nf0; } } if (std.string.find(s,"\n" ~ fn) == -1) // No filename repeats s ~= fn ~ "\n"; } //s = std.string.strip(s); //msgBox(s); return s; } after this, I will prepare s and UPDATE Xtra3. Here is the question: the original UPDATE should have worked, correct? Meaning that the filename'3.txt should have been prepared as filename''3.txt, correct? _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users