forked from Baseflow/flutter_cache_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32b71c1
commit 474d41d
Showing
3 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
flutter_cache_manager/lib/src/storage/file_system/file_name_validator.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
abstract class FileNameValidator { | ||
static final List<String> forbiddenWindowsCharacters = [ | ||
'<', | ||
'>', | ||
':', | ||
'"', | ||
'/', | ||
'\\', | ||
'|', | ||
'?', | ||
'*' | ||
]; | ||
static final List<String> forbiddenWindowsFileNames = [ | ||
'CON', | ||
'PRN', | ||
'AUX', | ||
'NUL', | ||
'COM1', | ||
'COM2', | ||
'COM3', | ||
'COM4', | ||
'COM5', | ||
'COM6', | ||
'COM7', | ||
'COM8', | ||
'COM9', | ||
'LPT1', | ||
'LPT2', | ||
'LPT3', | ||
'LPT4', | ||
'LPT5', | ||
'LPT6', | ||
'LPT7', | ||
'LPT8', | ||
'LPT9' | ||
]; | ||
|
||
static bool isValidFileName(String fileName) { | ||
// Check for forbidden characters in Windows | ||
for (final char in forbiddenWindowsCharacters) { | ||
if (fileName.contains(char)) return false; | ||
} | ||
|
||
// Check for forbidden file names in Windows | ||
if (forbiddenWindowsFileNames.contains(fileName.toUpperCase())) | ||
return false; | ||
|
||
// Check for Linux forbidden character (forward slash) | ||
if (fileName.contains('/')) return false; | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters