Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

LFN's -- Extract & rename under DOS

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

  • LFN's -- Extract & rename under DOS

    $if 0
    Using PB/DOS 3.5.....

    These two routines work great under windows 98. Would like to see
    if they work under other O/S's as well. If somebody would like to
    test them and get back to me, would really appreciate it. Please
    note that they have to be run with windows running in a DOS window.
    They won't work booting F8 boot-2-dos.

    The first code extracts the LFN from SFN.
    The second routine renames a file with LFN's allowed.

    As I said, both of them work on my machine running windows 98,
    but.....

    I owe a huge debt of thanks to somebody here on the forum for
    routing me in the right direction but I can't find his post to
    get the name. Soon as I get the name, I'll give him the thanks
    he so richly deserves.

    $endif

    Code:
            REM ************************            '
            REM * Extract LFN from SFN *            '
            REM ************************            '
                                                    '
    	$lib all off				'
            color 14,1                              '
            cls                                     '
                                                    '
            te$ = dir$("c:\*.*")			'
                                                    '
            do until te$ = ""			'
            te$ = "c:\" + te$ + chr$(0)		' ASCIIZ terminated
                                                    '
    	d$ = string$(260,chr$(255))             ' Max string len of LFN
            reg 1,&h7160                            '
            reg 3,2                                 '
                                                    '
    	reg 5,strptr(te$)			' Segment & offset of SFN
            reg 8,strseg(te$)                       ' buffer
                                                    '
            reg 6,strptr(d$)			' Segment & offset of LFN
            reg 9,strseg(d$)                        ' buffer
            call interrupt &h21                     '
                                                    '
            d$ = remove$(d$,chr$(255))              ' Remove excess characters
                                                    ' from buffer.
            locate 1,1 : print;te$;len(te$)         '
            locate 2,1 : print;d$;len(d$)           '
            while instat=0:wend                     '
            an$ = inkey$                            '
            if an$ = chr$(27) then exit loop        '
            te$ = dir$                              '
                                                    '
            loop                                    '
            end                                     '
    
    
            REM *******************************
            REM *                             *
            REM * Rename a file using short or*
            REM * long file names.            *
            REM *                             *
            REM *******************************
    
    
            path$ = "c:\mystuff\pb35\lfn\"
    
            oldname$ = path$ + "dummy.bat" + chr$(0)
            newname$ = path$ + "This is the renamed dummy batch file" + chr$(0)
    
            reg 1,&h7156                            '
                                                    '
    	reg 4,strptr(oldname$)			' Segment & offset of old
            reg 8,strseg(oldname$)			' file name
                                                    '
            reg 6,strptr(newname$)			' Segment & offset of new
            reg 9,strseg(newname$)			' file name
                                                    '
    	call interrupt &h21                     '
            end                                     '

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



    [This message has been edited by Mel Bishop (edited July 20, 2002).]
    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.

  • #2
    Should work in any DOS box from Win95 on, Mel, and some DOS extender
    products without Windows. See Ralf Brown's interrupt list in our
    Links area. As always, it would be prudent to check error codes.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment

    Working...
    X