[Libreoffice-commits] .: tools/source

François Tigeot ftigeot at kemper.freedesktop.org
Wed Jun 15 11:46:59 PDT 2011


 tools/source/fsys/dirent.cxx |  149 -------------------------------------------
 1 file changed, 149 deletions(-)

New commits:
commit 708279f34c1ce264a8877223e549148da7f5cfd6
Author: Francois Tigeot <ftigeot at wolfpond.org>
Date:   Wed Jun 15 20:43:48 2011 +0200

    We don't want to create MS-DOS short file names.

diff --git a/tools/source/fsys/dirent.cxx b/tools/source/fsys/dirent.cxx
index a188569..83b3ebd 100644
--- a/tools/source/fsys/dirent.cxx
+++ b/tools/source/fsys/dirent.cxx
@@ -662,7 +662,6 @@ DirEntry::DirEntry( const String& rInitName, FSysPathStyle eStyle )
         }
 
 #ifdef DBG_UTIL
-        // ASF nur bei Default eStyle, nicht z.B. aus MakeShortName()
         if( eStyle == FSYS_STYLE_HOST &&
             aTmpName.Search( "://" ) != STRING_NOTFOUND )
         {
@@ -709,7 +708,6 @@ DirEntry::DirEntry( const ByteString& rInitName, FSysPathStyle eStyle )
     }
 #ifdef DBG_UTIL
     else
-        // ASF nur bei Default eStyle, nicht z.B. aus MakeShortName()
         if( eStyle == FSYS_STYLE_HOST &&
             rInitName.Search( "://" ) != STRING_NOTFOUND )
         {
@@ -1844,37 +1842,6 @@ FSysError DirEntry::ImpParseUnixName( const ByteString& rPfad, FSysPathStyle eSt
     return FSYS_ERR_OK;
 }
 
-/*************************************************************************
-|*
-|*    DirEntry::MakeShortName()
-|*
-*************************************************************************/
-
-ErrCode CreateEntry_Impl( const DirEntry &rPath, DirEntryKind eKind )
-{
-    // versuchen, anzulegen (ausser bei FSYS_KIND_ALL)
-    ErrCode eErr = ERRCODE_NONE;
-    if ( FSYS_KIND_FILE == eKind )
-    {
-        SvFileStream aStream( rPath.GetFull(), STREAM_STD_WRITE );
-        aStream.WriteLine( "" );
-        eErr = aStream.GetError();
-    }
-    else if ( FSYS_KIND_ALL != eKind )
-        eErr = rPath.MakeDir() ? ERRCODE_NONE : ERRCODE_IO_UNKNOWN;
-
-    // erfolgreich?
-    if ( !rPath.Exists() )
-        eErr = ERRCODE_IO_UNKNOWN;  // Doch was schiefgegangen ?
-
-    // ggf. wieder l"oschen
-    if ( FSYS_KIND_NONE == eKind )
-        rPath.Kill();
-
-    // Fehlercode zur?ckliefern
-    return eErr;
-}
-
 sal_Bool IsValidEntry_Impl( const DirEntry &rPath,
                         const String &rLongName,
                         DirEntryKind eKind,
@@ -1921,122 +1888,6 @@ sal_Bool IsValidEntry_Impl( const DirEntry &rPath,
 #define MAX_LEN_MAX       255
 #define INVALID_CHARS_DEF   "\\/\"':|^<>?*"
 
-sal_Bool DirEntry::MakeShortName( const String& rLongName, DirEntryKind eKind,
-                              sal_Bool bUseDelim, FSysPathStyle eStyle )
-{
-        String aLongName(rLongName);
-
-        // Alle '#' aus den Dateinamen entfernen, weil das INetURLObject
-        // damit Probleme hat. Siehe auch #51246#
-        aLongName.EraseAllChars( '#' );
-        ByteString bLongName(aLongName, osl_getThreadTextEncoding());
-
-        // Auf Novell-Servern (wegen der rottigen Clients) nur 7bit ASCII
-
-        // bei FSYS_KIND_ALL den alten Namen merken und abh"angen (rename)
-        ByteString aOldName;
-        if ( FSYS_KIND_ALL == eKind )
-        {
-            aOldName = ByteString(CutName(), osl_getThreadTextEncoding());
-            aOldName = CMP_LOWER(aOldName);
-        }
-
-        // ist der Langname direkt verwendbar?
-        if ( IsValidEntry_Impl( *this, aLongName, eKind, sal_False, bUseDelim ) )
-        {
-            operator+=( DirEntry(aLongName) );
-            return sal_True;
-        }
-
-        // max L"angen feststellen
-        sal_uInt16 nMaxExt, nMaxLen;
-        if ( FSYS_STYLE_DETECT == eStyle )
-            eStyle = DirEntry::GetPathStyle( GetDevice().GetName() );
-        ByteString aInvalidChars;
-        nMaxExt = MAX_EXT_MAX;
-        nMaxLen = MAX_LEN_MAX;
-        aInvalidChars = INVALID_CHARS_DEF;
-
-        // Extension abschneiden und kuerzen
-        ByteString aExt;
-        ByteString aFName = bLongName;
-        DirEntry aUnparsed;
-        aUnparsed.aName = bLongName;
-        aExt = ByteString(aUnparsed.CutExtension(), osl_getThreadTextEncoding());
-        aFName = aUnparsed.aName;
-        if ( aExt.Len() > nMaxExt )
-        {
-            char c = aExt.GetChar( aExt.Len() - 1 );
-            aExt.Erase(nMaxExt-1);
-            aExt += c;
-        }
-
-        // ausser auf einem FAT-System geh"ort die Extension zur
-        // Maxl"ange. Muss also vorher mit dem Punkt abgezogen werden.
-        nMaxLen -= ( aExt.Len() + 1 );
-
-        // Name k"urzen
-        ByteString aSName;
-        for ( const char *pc = aFName.GetBuffer(); aSName.Len() < nMaxLen && *pc; ++pc )
-        {
-            if ( STRING_NOTFOUND == aInvalidChars.Search( *pc ) &&
-                 (unsigned char) *pc >= (unsigned char) 32 &&
-                 ( !aSName.Len() || *pc != ' ' || aSName.GetChar(aSName.Len()-1) != ' ' ) )
-                aSName += *pc;
-        }
-        aSName.EraseTrailingChars();
-
-        // HRO: #74246# Also cut leading spaces
-        aSName.EraseLeadingChars();
-
-        if ( !aSName.Len() )
-            aSName = "noname";
-
-        // kommt dabei der alte Name raus?
-        ByteString aNewName = aSName;
-        if ( aExt.Len() )
-            ( aNewName += '.' ) += aExt;
-        operator+=( DirEntry(String(aNewName, osl_getThreadTextEncoding())) );
-        if ( FSYS_KIND_ALL == eKind && CMP_LOWER(aName) == aOldName )
-        if ( FSYS_KIND_ALL == eKind && CMP_LOWER(ByteString(GetName(), osl_getThreadTextEncoding())) == aOldName )
-            return sal_True;
-
-        // kann der gek"urzte Name direkt verwendet werden?
-        if ( !Exists() && (ERRCODE_NONE == CreateEntry_Impl( *this, eKind )) )
-            return sal_True;
-
-        // darf '?##' verwendet werden, um eindeutigen Name zu erzeugen?
-        if ( bUseDelim )
-        {
-                // eindeutigen Namen per '?##' erzeugen
-            aSName.Erase( nMaxLen-3 );
-            if ( bUseDelim != 2 )
-                        aSName += FSYS_SHORTNAME_DELIMITER;
-            for ( int n = 1; n < 99; ++n )
-            {
-                // Name zusammensetzen
-                ByteString aTmpStr( aSName );
-                aTmpStr += ByteString::CreateFromInt32(n);
-                if ( aExt.Len() )
-                    ( aTmpStr += '.' ) += aExt;
-
-                // noch nicht vorhanden?
-                SetName( String(aTmpStr, osl_getThreadTextEncoding()) );
-
-                if ( !Exists() )
-                {
-                    // Fehler setzen !!!
-                    nError = CreateEntry_Impl( *this, eKind );
-                    return (ERRCODE_NONE == nError);
-                }
-            }
-        }
-
-        // keine ## mehr frei / ?## soll nicht verwendet werden
-        nError = ERRCODE_IO_ALREADYEXISTS;
-        return sal_False;
-}
-
 /*************************************************************************
 |*
 |*    DirEntry::CreatePath()


More information about the Libreoffice-commits mailing list