Changeset 25577 in webkit


Ignore:
Timestamp:
Sep 14, 2007, 5:10:45 PM (18 years ago)
Author:
oliver
Message:

Need to use _wstat instead of _stat to stat files on windows

_stat doesn't handle multibyte character sequences, unless (afaict)
the current codepage supports them, and then it uses the current
codepage. In order to correctly handle multibyte characters in a
file path we have to use _wstat.

In deference to the fact that the CF implementation may be used on
platforms other than windows i've added fileSize to the FileSystem
helper functions, and added a windows impl.

Location:
trunk/WebCore
Files:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r25576 r25577  
     12007-09-14  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Sam and Geoff.
     4
     5        <rdar://problem/5333272> Cannot upload files when path contains
     6        non-ascii/multibyte characters
     7
     8        We can't use _stat to determine file size on Windows as it may not
     9        correctly handle multibyte characters, so we have to use _wstat.
     10       
     11        In deference to the fact that we may one day use the FormDataStreamCFNet.cpp
     12        on Mac i've wrapped the call to _wstat with a generic fileSize
     13        method in FileSystem.h
     14
     15        * WebCore.vcproj/WebCore.vcproj:
     16        * platform/FileSystem.h:
     17        * platform/network/cf/FormDataStreamCFNet.cpp:
     18        * platform/win/FileSystemWin.cpp: Added.
     19        (WebCore::setHTTPBody):
     20        * platform/gdk/TemporaryLinkStubs.cpp:
     21        * platform/mac/FileSystemMac.mm:
     22        (WebCore::fileSize):
     23        * platform/qt/TemporaryLinkStubs.cpp:
     24
    1252007-09-14  Timothy Hatcher  <timothy@apple.com>
    226
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r25568 r25577  
    30283028                        </File>
    30293029                        <File
     3030                                RelativePath="..\platform\FileSystem.h"
     3031                                >
     3032                        </File>
     3033                        <File
    30303034                                RelativePath="..\platform\FloatConversion.h"
    30313035                                >
     
    34803484                                <File
    34813485                                        RelativePath="..\platform\win\FileChooserWin.cpp"
     3486                                        >
     3487                                </File>
     3488                                <File
     3489                                        RelativePath="..\platform\win\FileSystemWin.cpp"
    34823490                                        >
    34833491                                </File>
  • trunk/WebCore/platform/FileSystem.h

    r25081 r25577  
    3636bool fileExists(const String&);
    3737bool deleteFile(const String&);
     38bool fileSize(const String&, long long& result);
    3839
    3940} // namespace WebCore
  • trunk/WebCore/platform/gdk/TemporaryLinkStubs.cpp

    r25572 r25577  
    183183bool fileExists(const String& path) { notImplemented(); return false; }
    184184bool deleteFile(const String& path) { notImplemented(); return false; }
     185bool fileSize(const String& path, long long& result) { notImplemented(); return false; }
    185186void callOnMainThread(void (*)()) { notImplemented(); }
    186187}
  • trunk/WebCore/platform/mac/FileSystemMac.mm

    r25081 r25577  
    2929#import "FileSystem.h"
    3030
     31#import "NotImplemented.h"
    3132#import "PlatformString.h"
    3233
     
    5758}
    5859
     60bool fileSize(const String& path, long long& result)
     61{
     62    notImplemented();
     63    return false;
     64}
     65
    5966} //namespace WebCore
  • trunk/WebCore/platform/network/cf/FormDataStreamCFNet.cpp

    r23906 r25577  
    3333
    3434#include "CString.h"
     35#include "FileSystem.h"
    3536#include "FormData.h"
    3637#include <CFNetwork/CFURLRequestPriv.h>
    3738#include <CoreFoundation/CFStreamAbstract.h>
    38 #include <sys/stat.h>
    3939#include <sys/types.h>
    4040#include <wtf/Assertions.h>
     
    341341            length += element.m_data.size();
    342342        else {
    343             struct _stat64i32 sb;
    344             int statResult = _stat(element.m_filename.utf8().data(), &sb);
    345             if (statResult == 0 && (sb.st_mode & S_IFMT) == S_IFREG)
    346                 length += sb.st_size;
     343            long long size;
     344            if (fileSize(element.m_filename, size))
     345                length += size;
    347346            else
    348347                haveLength = false;
  • trunk/WebCore/platform/qt/TemporaryLinkStubs.cpp

    r25572 r25577  
    8484
    8585float userIdleTime() { notImplemented(); return 0.0; }
     86bool fileSize(const String& path, long long& result) { notImplemented(); return false; }
    8687
    8788}
  • trunk/WebCore/platform/win/FileSystemWin.cpp

    r25576 r25577  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
    29 #ifndef FileSystem_h
    30 #define FileSystem_h
     28
     29#include "config.h"
     30
     31#include "FileSystem.h"
     32#include "PlatformString.h"
     33
     34#include <sys/stat.h>
    3135
    3236namespace WebCore {
    3337
    34 class String;
     38bool fileSize(const String& inFilename, long long& result)
     39{
     40    struct _stat64i32 sb;
     41    String filename = inFilename;
     42    int statResult = _wstat(filename.charactersWithNullTermination(), &sb);
     43    if (statResult != 0 || (sb.st_mode & S_IFMT) != S_IFREG)
     44        return false;
     45    result = sb.st_size;
     46    return true;
     47}
    3548
    36 bool fileExists(const String&);
    37 bool deleteFile(const String&);
    38 
    39 } // namespace WebCore
    40 
    41 #endif // FileSystem_h
     49}
Note: See TracChangeset for help on using the changeset viewer.