OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. | 3 * Copyright (C) 2009 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 14 matching lines...) Expand all Loading... |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "platform/clipboard/ClipboardUtilities.h" | 28 #include "platform/clipboard/ClipboardUtilities.h" |
29 | 29 |
30 #include "wtf/text/StringBuilder.h" | 30 #include "wtf/text/StringBuilder.h" |
31 #include "wtf/text/WTFString.h" | 31 #include "wtf/text/WTFString.h" |
32 | 32 |
33 #include <shlwapi.h> | 33 #include <shlwapi.h> |
34 | 34 |
35 namespace WebCore { | 35 namespace blink { |
36 | 36 |
37 // FAT32 and NTFS both limit filenames to a maximum of 255 characters. | 37 // FAT32 and NTFS both limit filenames to a maximum of 255 characters. |
38 static const unsigned maxFilenameLength = 255; | 38 static const unsigned maxFilenameLength = 255; |
39 | 39 |
40 // Returns true if the specified character is not valid in a file name. This | 40 // Returns true if the specified character is not valid in a file name. This |
41 // is intended for use with removeCharacters. | 41 // is intended for use with removeCharacters. |
42 static bool isInvalidFileCharacter(UChar c) | 42 static bool isInvalidFileCharacter(UChar c) |
43 { | 43 { |
44 return !(PathGetCharType(c) & (GCT_LFNCHAR | GCT_SHORTCHAR)); | 44 return !(PathGetCharType(c) & (GCT_LFNCHAR | GCT_SHORTCHAR)); |
45 } | 45 } |
(...skipping 17 matching lines...) Expand all Loading... |
63 name = name.removeCharacters(&isInvalidFileCharacter); | 63 name = name.removeCharacters(&isInvalidFileCharacter); |
64 extension = extension.removeCharacters(&isInvalidFileCharacter); | 64 extension = extension.removeCharacters(&isInvalidFileCharacter); |
65 | 65 |
66 if (extension.length() >= maxFilenameLength) | 66 if (extension.length() >= maxFilenameLength) |
67 extension = String(); | 67 extension = String(); |
68 | 68 |
69 // Truncate overly-long filenames, reserving one character for a dot. | 69 // Truncate overly-long filenames, reserving one character for a dot. |
70 name.truncate(maxFilenameLength - extension.length() - 1); | 70 name.truncate(maxFilenameLength - extension.length() - 1); |
71 } | 71 } |
72 | 72 |
73 } // namespace WebCore | 73 } // namespace blink |
OLD | NEW |