Announcement

Collapse
No announcement yet.

SFN vs. LFN ??

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

  • Robert E. Carneal
    replied
    Merry Christmas.
    Thank you.

    Robert

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

    Leave a comment:


  • Frank Cox
    replied
    > I wish I could buy a "MS-DOS INT 0x71 reference guide."
    http://www-2.cs.cmu.edu/afs/cs/user/...WWW/files.html

    Merry Christmas.

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

    Leave a comment:


  • Robert E. Carneal
    replied
    Michael-

    That's probably what I will do. This is the first time I have had to write an application AND be backward compatiable to at least DOS in Windows 98Fe.

    For the first time since I have gotten Powerbasic, I find myself wishing for an "All-Windows emulator" that will simulate earch version of Windows so I wouldn't have to find someone who has W98Fe, Win98Se, WinME, etc.

    Thank you.

    Robert

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

    Leave a comment:


  • Michael Mattias
    replied
    > have it set to check a file name and if the tilde is inside the name, it auto-assumes it is a SFN and needs to get the LFN.

    So why not just check 'em all?

    Don't check the file name for speed purposes: by the time you get doing screwing around checking lengths and for the presence of exactly one tilde exactly two characters short of the 'dot' with a numeric digit one character before the dot, the filename could have been "LFN'd" already.


    Leave a comment:


  • Robert E. Carneal
    replied
    I wish I could buy a "MS-DOS INT 0x71 reference guide." I think the error problem is me, the programmer.

    I have it set to check a file name and if the tilde is inside the name, it auto-assumes it is a SFN and needs to get the LFN. When it gets the "LFN", it is checked again. If it still has the Tilde, do it again until it successfuly gets a name without the Tilde.

    When I don't program it that way, I seem to miss a lot of LFN filenames. So I am trying a few ideas, maybe I will hit one that will tell me the file name with a Tilde is indeed the LFN.

    Thanks, guys.

    Robert

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

    Leave a comment:


  • Michael Mattias
    replied
    My comment was totally, absolutely gratuitous and has nothing to do with your problem.. it just demonstrates "how" once could get a 'real' file name which only looks like the short file name version of a long file name.

    But on your problem.. I would assume that your "get the long name" function which uses int &h71 could be modified to return an error code...I'm not an assembly-language type, but it seems to me...
    Code:
     jnc exitsuccess
    .. implies the function only succeeded in obtaining a long name if the carry flag is clear, and it failed if the carry flag is set.

    Maybe you should check the carry flag carefully. If the function succeeds and the 'long name' comes back with a tilde in it, then the 'real' name of the file really does contain a tilde.

    But you should get an opinion from someone with an MS-DOS INT 0x71 reference guide.

    MCM

    Leave a comment:


  • Robert E. Carneal
    replied
    Sorry, Michael, I rewrote that several times trying to make it clearer. I guess I should have said what if the file name uses the "~" character as part of the name, and it doesn't mean the name is longer? How do I determine that?

    Robert

    [This message has been edited by Robert E. Carneal (edited February 18, 2005).]

    Leave a comment:


  • Michael Mattias
    replied
    >What if the name "Robert~1.txt" is actually the full name

    The PB/DLL version 6.0 IDE did that.. load a file, even if it had a long name )the short name appeared in the OPEN dialog), when you saved it, it got saved as the short name.

    <U>Very</U> confusing for me until I figured out what was going on....

    (Updated in PB/DLL 6.10 which added 'real' long file name support)

    Leave a comment:


  • Thomas Gohel
    replied

    On 18 Feb 05, Robert E. Carneal wrote:

    Hello Robert,

    > A problem surfaced today. What if the name "_Robert~1.txt_" is
    > actually the full name? Because of the "~" character, my routine
    > keeps attempting to obtain the long file name of this. Does anyone
    > know how to obtain a file name and also along with it a indicator of
    > some sort to show if it is the Full name or short name? That way, if
    > it is the short name, I can obtain the full name, if it is already
    > the full name, go to the next name?

    Very old stuff, but it works ...

    Code:
    '************************************************************************
    '
    '  NAME95.BAS  Konvertierung von Dateinamen von/nach DOS8.3 <-> LFN
    '              Konvention mit PowerBASIC 3.2
    '
    '  entwickelt von Thomas Gohel  FidoNet :  Thomas [email protected]:2410/330.1
    '  Version: 1.00                InterNet:   [url="mailto:[email protected]"]mailto:[email protected][/url][email protected]</A> 
    '  Stand  : 16.11.1996          Homepage:  [url="http://www.pbhq.de/"]http://www.pbhq.de/[/url] 
    '
    '*************************************************************************
    
    DECLARE FUNCTION GetStrLoc (BYVAL INTEGER) AS INTEGER
    
    CLS
    PRINT "Erzeuge LFN-Files  : "; Win95Open$("C:\Testfile1.Test")
    PRINT "Erzeuge LFN-Files  : "; Win95Open$("C:\Testfile2.Test")
    PRINT "Erzeuge LFN-Files  : "; Win95Open$("C:\Testfile3.Test")
    PRINT "---------------------------------------------"
    PRINT "Ermittele LFN alias: "; Win95Pfad$("C:\TESTFI~1.TES")
    PRINT "Ermittele LFN alias: "; Win95Pfad$("C:\TESTFI~2.TES")
    PRINT "Ermittele LFN alias: "; Win95Pfad$("C:\TESTFI~3.TES")
    PRINT "---------------------------------------------"
    PRINT "Ermittele DOS alias: "; Dos83Pfad$("C:\Testfile1.Test")
    PRINT "Ermittele DOS alias: "; Dos83Pfad$("C:\Testfile2.Test")
    PRINT "Ermittele DOS alias: "; Dos83Pfad$("C:\Testfile3.Test")
    
    FUNCTION Dos83Pfad$(BYVAL DirLFN$) public
            DIM LFNBuffer AS STRING * 128
            DirLFN$ = DirLFN$ + CHR$(0)
    
            ! push ds
            ! lea  di, LFNBuffer$
            ! push ds                         ; ES [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]I auf Stack, erspart außer-
            ! push di                         ; das leidige Umkopieren
    
            ! les  di, DirLFN$                ; Handle von DirLFN$ holen
            ! push di                         ; auf Stack
            ! call GetStrLoc                  ; Adresse holen
            ! mov  ds, dx                     ; Quelle auf DS:SI umkopieren
            ! mov  si, ax                     ;
    
            ! pop  di                         ; ES [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]I umkopiert vom Stack holen
            ! pop  es                         ;
    
            ! mov  ax, &h7160                 ; Make DOS 8.3 Names
            ! mov  ch, 0
            ! mov  cl, 1
            ! int  &h21
            ! pop  ds
            i% = INSTR(1, LFNBuffer$, CHR$(0))
            Dos83Pfad$ = LEFT$(LFNBuffer$, i%-1)
    END FUNCTION
    
    FUNCTION Win95Pfad$(BYVAL DirLFN$) public
            DIM LFNBuffer AS STRING * 128
            DirLFN$ = DirLFN$ + CHR$(0)
    
            ! push ds
            ! lea  di, LFNBuffer$
            ! push ds                         ; ES [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]I auf Stack, erspart außer-
            ! push di                         ; das leidige Umkopieren
    
            ! les  di, DirLFN$                ; Handle von DirLFN$ holen
            ! push di                         ; auf Stack
            ! call GetStrLoc                  ; Adresse holen
            ! mov  ds, dx                     ; Quelle auf DS:SI umkopieren
            ! mov  si, ax                     ;
    
            ! pop  di                         ; ES [img]http://www.powerbasic.com/support/forums/biggrin.gif[/img]I umkopiert vom Stack holen
            ! pop  es                         ;
    
            ! mov  ax, &h7160                 ; Make Win95 Names
            ! mov  ch, 0
            ! mov  cl, 2
            ! int  &h21
            ! pop  ds
            i% = INSTR(1, LFNBuffer$, CHR$(0))
            Win95Pfad$ = LEFT$(LFNBuffer$, i%-1)
    END FUNCTION
    
    FUNCTION Win95Open$(BYVAL Filename$)
            Filename$ = Filename$ + CHR$(0)
            ! push ds
            ! les  di, Filename$              ; Handle von Filename$ holen
            ! push di                         ; auf Stack
            ! call GetStrLoc                  ; Adresse holen
            ! mov  ds, dx                     ; Quelle auf DS:SI umkopieren
            ! mov  si, ax                     ;
            ! mov  ax, &h716C
            ! mov  bx, &h0002
            ! mov  cx, &h0000
            ! mov  dx, &h0012
            ! mov  di, 1
            ! int  &h21
            ! pop  ds
            ! mov  bx, ax                      ; und File wieder schliessen
            ! mov  ah, &h3E
            ! int  &h21
            Win95Open$ = Dos83Pfad$(Filename$)
    END FUNCTION
    If you need some other LFN stuff, too:
    http://www.pbhq.de/cgi-bin/pbsearch.exe?description=lfn
    http://www.pbhq.de/cgi-bin/pbsearch....cription=DIR95

    Regards,

    --------------
    / h o m a s
    ------------------
    email : [email protected] / mailto:[email protected][email protected]</A> (PGP-Key available)
    www : http://www.gohel.de / http://www.pbhq.de (PowerBASIC)
    chat : irc://irc.pbhq.de/#pbhq.cafe (Online-Chat for PB users only!)
    bbs : telnet://bbs.pbhq.de (historical access to the PBSOUND HQ BBS)
    ## CrossPoint/Agent R/C2478, via PBNEWS v0.56g (news.pbhq.de)

    Leave a comment:


  • Bob Green
    replied
    This might work for you (needs Windows or in pure DOS an API
    like DOSLFN.) The function returns the long pathname, if one
    exists, or else the short pathname is returned.

    FUNCTION getlongname (BYVAL shortpathname AS STRING) PUBLIC AS STRING

    dim longname AS STRING * 1024
    shortpathname = shortpathname + chr$(0)
    longptr??? = VARPTR32(longname)
    shortptr??? = STRPTR32(shortpathname)

    FUNCTION = ""

    ! push ds
    ! lds si, shortptr???
    ! les di, longptr???
    ! mov cx, 2
    ! mov ax, &H7160
    ! int &H21
    ! pop ds
    ! jnc exitsuccess

    EXIT FUNCTION

    exitsuccess:

    FUNCTION = REMOVE$(longname, CHR$(0))

    END FUNCTION

    ------------------
    Bob Green
    FileRecovery.Biz

    [This message has been edited by Bob Green (edited February 18, 2005).]

    Leave a comment:


  • Frank Cox
    replied
    Why not get the short filename, get the long filename, and compare them?

    I don't know which routine you're using to get long file names, but there must be a way to insert a check for an empty string somewhere in there if there is no lfn found.

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

    Leave a comment:


  • Robert E. Carneal
    started a topic SFN vs. LFN ??

    SFN vs. LFN ??

    As a test, I did a reading of my C drive from Powerbasic, which yielded filenames such as:
    Kentuc~1,txt
    Indian~1.txt
    Indian~2.txt

    and so on. I have a routine which will look for those names and return the long file name.

    A problem surfaced today. What if the name "Robert~1.txt" is actually the full name? Because of the "~" character, my routine keeps attempting to obtain the long file name of this. Does anyone know how to obtain a file name and also along with it a indicator of some sort to show if it is the Full name or short name? That way, if it is the short name, I can obtain the full name, if it is already the full name, go to the next name?

    It hangs here, I have set to keep trying until it gets the long file name. Any suggestions? Would it work to just try to get the LFN only once, and if that fails, assume the "~" is part of the name and that it is the complete name?

    Thank you.

    Robert



    [This message has been edited by Robert E. Carneal (edited February 18, 2005).]
Working...
X