Announcement

Collapse
No announcement yet.

file names with ~

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • file names with ~

    Hello how to open...

    open "O",1,"C:\testho~1\myfile.txt"

    The error "file not found" occurs.

    Thanks for answere.

    Matthias Kuhn

    ------------------

  • #2
    Depending on what operating system you are using, the tiddle "~"
    may be a reserved character. Windows 95 and up uses it to
    associate the 8x3 short file name with the long file name. The
    operating system may not allow the use of that character with
    user defined file names.

    It may also be that the sub-directory doesn't exist or stray
    characters may be in the file name.

    ------------------


    [This message has been edited by Mel Bishop (edited December 17, 2000).]
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      It is important to note that the tilde character (~) is the _default_ character used by Windows to convert long files names to short file names, but that character can be changed by a registry "hack".

      I'm afraid I don't have any code to query the character that is in use by Windows, however, since every Windows' installation includes a directory called "Program Files", it should be possible to use A$ = DIR$("PROGRA?1",16) to return that directory name and then check the character used in the 7th position. While this is not guaranteed to be fool-proof, it may help with a useful solution.


      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Sorry Mel and Lance,

        I`ve made a mistake: the tide Charakter "~" chr$(126)
        is the right one.

        I use Win 95 and it is possible to open file in those directories
        with pb 3.5.

        Regards

        Matthias Kuhn


        ------------------

        Comment


        • #5
          In case people are interested... I've made a unit that 'replaces' the OPEN, CLOSE,
          KILL, NAME etc. from PowerBasic and supports long filenames. It's nearly finished
          It has some other really useful file-related abilities. The unit will be part of a
          collection of units I will release for free on my homepage soon...
          Mail me if you're interested

          The release will be announced at the Third Party Add-On forum, so watch for it!


          ------------------
          Sebastian Groeneveld
          mailto:[email protected][email protected]</A>
          Sebastian Groeneveld
          mailto:[email protected][email protected]</A>

          Comment


          • #6
            Sounds interesting! There are a few examples of LFN handling around, including one in the FILES section of this web site.

            Will your library require Windows to be running in order to function, or will it work with plain DOS (boot to MSDOS) mode?


            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Unfortunately my knowledge of absolute disk reading is not sufficient to use it
              for this unit. I've been looking too for a tool that can handle long filenames in
              plain DOS. And there are some nice TSR utilities that do the job... The purpose of
              this unit was to provide a single function call that would work for both long filenames
              in Win95 and short filenames in Win95 or plain DOS. However, there's also a function
              that converts any given long filename to a proper 8.3 format (optionally using "~1"
              stuff)...

              In conclusion, the unit uses many routines that can also be found in WinLib, and
              therefore needs Win95 be running in the background.

              A question for people running Win2k or WinNT:
              The following code will only detect Win9x, not WinNT/2k:
              Code:
                ! mov   ax, &H1600
                ! int   &H2F
                ! cmp   al, 4
                ! jnz   NotWin95
              However, Lance has shown a trick to detect WinNT/2k:
              Code:
                IF UCASE$(ENVIRON$("OS")) = "WINDOWS_NT" THEN
                    FUNCTION = -1
                    EXIT FUNCTION
                END IF
              Now my question:
              Will the other functions in WinLib (getting the LFN/SFN, switching to fullscreen,
              etc...) work properly under WinNT/2k... in other words, is it useful to add this
              'Lance-trick' to the Win95Check, that is used to verify that the LFN/SFN functions
              can be used?

              ------------------
              Sebastian Groeneveld
              mailto:[email protected][email protected]</A>

              [This message has been edited by Sebastian Groeneveld (edited December 19, 2000).]
              Sebastian Groeneveld
              mailto:[email protected][email protected]</A>

              Comment

              Working...
              X