You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- >>> isValidSnapshotName "com1" -- "com2", "com3", etc.
168
+
-- False
169
+
-- >>> isValidSnapshotName "lpt1" -- "lpt2", "lpt3", etc.
170
+
-- False
140
171
--
141
-
mkSnapshotName::String->MaybeSnapshotName
142
-
mkSnapshotName s
143
-
|all isValid s
144
-
, len >0
145
-
, len <65
146
-
, System.FilePath.Posix.isValid s
147
-
, System.FilePath.Windows.isValid s
148
-
=Just (MkSnapshotName s)
149
-
150
-
|otherwise
151
-
=Nothing
172
+
-- See, e.g., [the VBA docs for the "Bad file name or number" error](https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/bad-file-name-or-number-error-52).
173
+
isValidSnapshotName::String->Bool
174
+
isValidSnapshotName str =
175
+
and [ all isValidChar str
176
+
, strLength >=1
177
+
, strLength <=64
178
+
, System.FilePath.Posix.isValid str
179
+
, System.FilePath.Windows.isValid str
180
+
]
152
181
where
153
-
len =length s
154
-
isValid c = ('a'<= c && c <='z') || ('0'<= c && c <='9' ) || c `elem`"-_"
182
+
strLength::Int
183
+
strLength =length str
184
+
isValidChar::Char->Bool
185
+
isValidChar c = ('a'<= c && c <='z') || ('0'<= c && c <='9' ) || c `elem`"-_"
186
+
187
+
--| Create snapshot name.
188
+
--
189
+
-- The given string must satsify 'isValidSnapshotName'.
190
+
--
191
+
-- Throws the following exceptions:
192
+
--
193
+
-- ['InvalidSnapshotNameError']:
194
+
-- If the given string is not a valid snapshot name.
0 commit comments