Changeset 1174

Show
Ignore:
Timestamp:
2007-12-04 14:16:53 (8 months ago)
Author:
fredck
Message:

Fixed #415 : The file browser connector will not work properly on "Medium" trust web sites.

Location:
FCKeditor.Net/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor.Net/trunk/Util.cs

    r1167 r1174  
    5656                public static DirectoryInfo CreateDirectory( string path ) 
    5757                { 
    58                         ArrayList oDirsToCreate = new ArrayList() ; 
    59  
    6058                        // Create the directory info object for that dir (normalized to its absolute representation). 
    6159                        DirectoryInfo oDir = new DirectoryInfo( Path.GetFullPath( path ) ) ; 
    6260 
     61                        try 
     62                        { 
     63                                // Try to create the directory by using standard .Net features. (#415) 
     64                                if ( !oDir.Exists ) 
     65                                        oDir.Create(); 
     66 
     67                                return oDir; 
     68                        } 
     69                        catch 
     70                        { 
     71                                CreateDirectoryUsingDll( oDir ); 
     72 
     73                                return new DirectoryInfo( path ); 
     74                        } 
     75                } 
     76 
     77                private static void CreateDirectoryUsingDll( DirectoryInfo dir ) 
     78                { 
     79                        // On some occasion, the DirectoryInfo.Create() function will  
     80                        // throw an error due to a bug in the .Net Framework design. For 
     81                        // example, it may happen that the user has no permissions to 
     82                        // list entries in a lower level in the directory path, and the 
     83                        // Create() call will simply fail. 
     84                        // To workaround it, we use mkdir directly. 
     85 
     86                        ArrayList oDirsToCreate = new ArrayList(); 
     87 
    6388                        // Check the entire path structure to find directories that must be created. 
    64                         while ( oDir != null && !oDir.Exists ) 
     89                        while ( dir != null && !dir.Exists ) 
    6590                        { 
    66                                 oDirsToCreate.Add( oDir.FullName ) ; 
    67                                 oDir = oDir.Parent ; 
     91                                oDirsToCreate.Add( dir.FullName ); 
     92                                dir = dir.Parent; 
    6893                        } 
    6994 
    70                         // "oDir == null" means that the check arrives in the root and it doesn't exist too. 
    71                         if ( oDir == null ) 
    72                                 throw( new System.IO.DirectoryNotFoundException( "Directory \"" + oDirsToCreate[ oDirsToCreate.Count-1 ] + "\" not found." ) ) ; 
     95                        // "dir == null" means that the check arrives in the root and it doesn't exist too. 
     96                        if ( dir == null ) 
     97                                throw ( new System.IO.DirectoryNotFoundException( "Directory \"" + oDirsToCreate[ oDirsToCreate.Count - 1 ] + "\" not found." ) ); 
    7398 
    7499                        // Create all directories that must be created (from bottom to top). 
    75                         for( int i = oDirsToCreate.Count - 1 ; i >= 0 ; i-- ) 
     100                        for ( int i = oDirsToCreate.Count - 1 ; i >= 0 ; i-- ) 
    76101                        { 
    77                                 string sPath = (string)oDirsToCreate[i] ; 
    78                                 int iReturn = _mkdir( sPath ) ; 
     102                                string sPath = (string)oDirsToCreate[ i ]; 
     103                                int iReturn = _mkdir( sPath ); 
    79104 
    80105                                if ( iReturn != 0 ) 
    81                                         throw new ApplicationException("Error calling [msvcrt.dll]:_wmkdir(" + sPath + "), error code: " + iReturn ); 
     106                                        throw new ApplicationException( "Error calling [msvcrt.dll]:_wmkdir(" + sPath + "), error code: " + iReturn ); 
    82107                        } 
    83  
    84                         return new DirectoryInfo( path ) ; 
    85108                } 
    86109        } 
  • FCKeditor.Net/trunk/_whatsnew.html

    r1173 r1174  
    6565                        and uploader will now correctly handle the Tilde ("~") in the UserFilesPath setting. 
    6666                </li> 
     67                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/415">#415</a>] The file 
     68                        browser connector will not work properly on "Medium" trust web sites.</li> 
    6769        </ul> 
    6870        <h3>