Long-Path Library

Started by Theo Gottwald, March 09, 2012, 07:30:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

NTFS supports pathes up to 32767 unicode characters.

QuoteMicrosoft Windows uses the following types of paths:
local file system (LFS), such as C:\File,
uniform naming convention (UNC), such as \\Server\Volume\File,
Long UNC or UNCW, such as \\?\C:\File or \\?\UNC\Server\Volume\File.

I have to say that the windows standard tools like the explorer do not work with such long pathes.
And most programs do not (yet) support these also. Therefore this is a special issue.

Peter has provided a first implementation of a Large-Path Library. It substitutes the PB-commands with Commands that will enable you to utilize that large pathes.

[Theo: Attachement changed to newer version, 26.12.2014]
Download Wide-Path Library

Peter Weis

#1
 ;) Theo ich muss dir widersprechen. Das Ding ist absolut kugelsicher. Hatte keinen einzigen Ausfall die letzten beiden Jahre! hat alles kopiert und gelöscht ordnungsgemäß ohne Fehler!

Theo, I have to disagree with you. This thing is absolutely bulletproof. Had not a single failure, the last two years! has copied everything and deleted correctly without any errors!


Grüße Peter ;D

Theo Gottwald

#2
I have now checked Peters Code and it has shown up that there were no bugs in the whole library.
Peters code is remarkable bug free. I have also corrected the Link and reduced the filesize to ~14 MB.
I have removed some obsolete posts so we can concentrate on further issues.

Peter Weis

#3
Habe die Function WideCopyDir verändert. So das eine Datei die schon existiert und Readonly ist auch überschrieben wird, und nicht abgebrochen wird :)

Have changed the Function WideCopydir. So that the file already exists and is read-only will be overwritten, and will not be canceled


FUNCTION WideCopyDir ALIAS "WideCopyDir"(BYVAL pSource AS WSTRING, BYVAL Pdest AS WSTRING, BYVAL bFailIfExists AS LONG, OPT BYREF recusive AS LONG) EXPORT AS LONG

    LOCAL fcount AS LONG
    LOCAL i AS LONG
    LOCAL f AS WSTRING
    LOCAL d1 AS WSTRING
    LOCAL p1 AS WSTRING
    LOCAL f1 AS WSTRING
    LOCAL l AS LONG

    LOCAL lstring AS ASCIZ * 32000



    wsplitf psource, d1, p1, f1
    Psource = RTRIM$(psource, "\")

    l = LEN(d1) + LEN(p1) + 1

    pdest = TRIM$(pdest)
    IF RIGHT$(pdest, 1) <> "\" THEN
        pdest = pdest + "\"
    END IF


    IF WideIsFolder(psource) THEN
        WideMkdir(pdest + f1)

        LOCAL dirclass AS WidedirRead
        LET dirclass = CLASS "WideDirReadCom"
        IF ISOBJECT(dirclass) THEN
            IF NOT ISMISSING(recusive) THEN
                fcount = dirclass.WideDirReadX(pSource + "\*", %F_NOT_PREV_DIR OR %F_NOT_THIS_DIR, recusive)
            ELSE
                fcount = dirclass.WideDirReadX(pSource + "\*", %F_NOT_PREV_DIR OR %F_NOT_THIS_DIR)
            END IF

            IF WideisFolder(pdest + LTRIM$(f1, "\")) THEN


                FOR i = 1 TO dirclass.dircount()
                    f = Pdest + LTRIM$(MID$(dirclass.FName(i), l), "\")

                    IF (dirclass.FGetattr(i) AND %FILE_ATTRIBUTE_DIRECTORY) THEN
                        WideMkdir f

                    ELSE
                        IF WideCopyFile (dirclass.FName(i), f, bFailIfExists) = 0 THEN
                            IF bFailIfExists = 0 THEN
                                WideSetAttr(f, widegetattr(f) AND &HFFFFFFFC)
                                IF WideCopyFile (dirclass.FName(i), f, bFailIfExists) <> 0 THEN
                                    ITERATE FOR
                                END IF
                                dirclass = NOTHING
                                EXIT FUNCTION
                            END IF
                        END IF
                    END IF
                NEXT i
                FUNCTION = %true
            END IF
        END IF
        dirclass = NOTHING

    END IF

END FUNCTION