file.copy issues

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • CPR
    Forum Member
    • Jan 2007
    • 3

    file.copy issues

    Is it possible to use relative file paths? I can't find anything on this subject, but it appears that a full path is always needed.

    I need to copy a file from an Install directory up one directory (to the App dir.). The problem is that my patch is in the Install dir. I can reference the source file with:

    _SourceFolder .. "\\test.txt"

    but how do I reference the destination dir? The source dir is:

    C:\Program Files\WCP\Install

    and the destination dir is:

    C:\Program Files\WCP

    The only solution I can think of (without being able to use relative paths) is to have the patch in C:\Program Files\WCP. Then I should be able to reference the Install dir with something like:

    _SourceFolder .. "\\Install\\test.txt"

    Any suggestions?

    Thanks for any help,

    Chuck
  • Lorne
    Indigo Rose Staff Member
    • Feb 2001
    • 2729

    #2
    Originally posted by CPR View Post
    Is it possible to use relative file paths? I can't find anything on this subject, but it appears that a full path is always needed.

    I need to copy a file from an Install directory up one directory (to the App dir.). The problem is that my patch is in the Install dir. I can reference the source file with:

    _SourceFolder .. "\\test.txt"

    but how do I reference the destination dir? The source dir is:

    C:\Program Files\WCP\Install

    and the destination dir is:

    C:\Program Files\WCP

    The only solution I can think of (without being able to use relative paths) is to have the patch in C:\Program Files\WCP. Then I should be able to reference the Install dir with something like:

    _SourceFolder .. "\\Install\\test.txt"

    Any suggestions?
    If the Program Files\WCP folder is the application folder location detected by your patch, you could use the %AppFolder% session variable like so:

    Code:
    SessionVar.Expand("%AppFolder%")
    Last edited by Lorne; 01-03-2007, 02:21 PM. Reason: Edited to say what I meant, and not what I said. :)
    --[[ Indigo Rose Software Developer ]]

    Comment

    • CPR
      Forum Member
      • Jan 2007
      • 3

      #3
      Isn't the AppFolder the one that I am running the patch from? In my case, the app folder is one folder higher. I am patching a file one folder below the app folder.

      Comment

      • Lorne
        Indigo Rose Staff Member
        • Feb 2001
        • 2729

        #4
        _SourceFolder is where your patch is running from.

        %AppFolder% is the root folder where your software is installed -- the location of the software to be patched. %AppFolder% is typically determined by your patch, normally in the On Startup script.

        In order for your patch to work it needs to find and identify the software to be patched...so by definition %AppFolder% should already be pointing to this:

        C:\Program Files\WCP

        So your destination folder would just be SessionVar.Expand("%AppFolder%").
        --[[ Indigo Rose Software Developer ]]

        Comment

        • CPR
          Forum Member
          • Jan 2007
          • 3

          #5
          Thanks, I'll try that, although I don't know how the software is going to know that my app is installed in a higher directory. The file being patched is in a sub-dir and NO files in the "app" dir are referenced in the patch. This is because I need an unopened version of the Access database to patch, and I keep that file in my Install directory. After the patch, I copy the patched file up one dir and rename. Perhaps I need to set up VP differently. I guess that all this discussion means that relative paths are not supported.
          Last edited by CPR; 01-03-2007, 06:51 PM.

          Comment

          • Lorne
            Indigo Rose Staff Member
            • Feb 2001
            • 2729

            #6
            Originally posted by CPR View Post
            Thanks, I'll try that, although I don't know how the software is going to know that my app is installed in a higher directory. The file being patched is in a sub-dir and NO files in the "app" dir are referenced in the patch.
            Ah, in that case then %AppDir% will probably point to that sub-dir where the file you're patching is located.

            Does your installer/application store any paths in the registry, or in the user profile? If so, you could read the location from there, and use that for the file copy.

            You could also just parse the path (either _SourceFolder or %AppFolder%) using string functions to get the path to their parent folder.

            In fact, here's a little function to do just that:
            Code:
            function GetParentFolder(FolderPath)
            	local strPath = String.TrimRight(FolderPath, "\\");
            	local nLastSlashPos = String.ReverseFind(strPath, "\\", true);
            	return String.Left(strPath, nLastSlashPos-1);
            end
            I guess that all this discussion means that relative paths are not supported.
            Yeah, I checked the source code and there is a validation function that is rejecting anything that isn't formatted as an absolute path or UNC path. It looks to me like relative paths were supported at one point, and I'm pretty sure they would still work if they were allowed through. I've logged it as a bug to be addressed in the next minor update (REF: 14465).
            --[[ Indigo Rose Software Developer ]]

            Comment

            Working...
            X