CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #5
    Join Date
    May 2009
    Location
    Boston
    Posts
    375

    Re: opening files were name contains '

    Quote Originally Posted by laserlight View Post
    Does filePath contain the correct file name?
    This is an interesting question. There may be a problem in that the list of file names comes out of excel and is then processed by a bash script. It looks like there may be more than one version of the single quote in excel. I can do a search in excel for a file name, and it says it's not there, but I can clearly see the file name. It looks like the single quote in excel is a bit different, like a close quote (slightly curved). If I change to the single quote from the keyboard, I can find the file. The file names were copied from a website, so I don't know if there is a different font there, etc. Are there more than one kind of single quote in ASCII? Single quotes are a pain in that all of the different tools I am using seem to handle then differently.

    Presuming that the file path is correct and matches an actual file, is there any reason why I should have to handle the single quote differently than other characters. I wouldn't expect it to need to be escaped, like in a bash script or something like that.

    Quote Originally Posted by Paul McKenzie View Post
    Well instead of all that code, where we don't know what's behind all of those variables, why not post a program that proves that you have an issue?
    I certainly can post the entire program, but it's a few hundred lines and I didn't know if anyone wanted to bother to sift through all of that. I have used this app for quite a while and it has worked fine. Suddenly today, it said it couldn't open files that were actually there. All of the problem file names contain ', so I started tracking down if there was an issue with that, such as if cpp looked at that as a regular expression.

    The output is a revised format of the input information. I have attached the src and test files.

    This was built with,
    g++ -O2 -o sdf_build.exe sdf_build_j.cpp; strip sdf_build.exe

    and run as,
    ./sdf_build.exe -d test_molfiles/ -k _keep_build.txt -i makesdf_test_input.txt -o test_output.sdf

    The file test_output.sdf is the correct output. With the files in the .zip, this runs correctly, which isn't much help. There must be something about the single quote from my excel files that is the problem, since I am able to get it to work with these files.

    Tomorrow I will try again to replicate the list of files that doesn't work from excel. Hopefully someone can spot what the difference is.

    Quote Originally Posted by Mavens View Post
    Are you creating your filePath string with escape sequences for directories?
    eg. "c:\\C++\\test.txt"
    File path is just a concatenation of a file name, and the directory that is passed in as in argument. The path is always relative and the directory is always in pwd. This is not a very sophisticated method, but the app is never used in cases where these conditions are not true, so I didn't include a way to use a full path. There is code that adds ./ to the dir_name/ that is passed in.

    LMHmedchem
    Attached Files Attached Files
    Last edited by LMHmedchem; June 8th, 2012 at 02:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured