@@ -156,14 +156,14 @@ public static boolean isPathInDirPath(String path, String dirPath, boolean ensur
156
156
* failed, otherwise {@code null}.
157
157
*/
158
158
public static String validateRegularFileExistenceAndPermissions (final Context context , final String path , final String parentDirPath , String permissionsToCheck , final boolean setMissingPermissions , final boolean ignoreErrorsIfPathIsUnderParentDirPath ) {
159
- if (path == null || path .isEmpty ()) return context .getString (R .string .null_or_empty_file );
159
+ if (path == null || path .isEmpty ()) return context .getString (R .string .error_null_or_empty_file );
160
160
161
161
try {
162
162
File file = new File (path );
163
163
164
164
// If file exits but not a regular file
165
165
if (file .exists () && !file .isFile ()) {
166
- return context .getString (R .string .non_regular_file_found );
166
+ return context .getString (R .string .error_non_regular_file_found );
167
167
}
168
168
169
169
boolean isPathUnderParentDirPath = false ;
@@ -183,7 +183,7 @@ public static String validateRegularFileExistenceAndPermissions(final Context co
183
183
// If path is not a regular file
184
184
// Regular files cannot be automatically created so we do not ignore if missing
185
185
if (!file .isFile ()) {
186
- return context .getString (R .string .no_regular_file_found );
186
+ return context .getString (R .string .error_no_regular_file_found );
187
187
}
188
188
189
189
// If there is not parentDirPath restriction or path is not under parentDirPath or
@@ -197,7 +197,7 @@ public static String validateRegularFileExistenceAndPermissions(final Context co
197
197
}
198
198
// Some function calls may throw SecurityException, etc
199
199
catch (Exception e ) {
200
- return context .getString (R .string .validate_file_existence_and_permissions_failed_with_exception , path , e .getMessage ());
200
+ return context .getString (R .string .error_validate_file_existence_and_permissions_failed_with_exception , path , e .getMessage ());
201
201
}
202
202
203
203
return null ;
@@ -230,14 +230,14 @@ public static String validateRegularFileExistenceAndPermissions(final Context co
230
230
* failed, otherwise {@code null}.
231
231
*/
232
232
public static String validateDirectoryExistenceAndPermissions (final Context context , final String path , final String parentDirPath , String permissionsToCheck , final boolean createDirectoryIfMissing , final boolean setMissingPermissions , final boolean ignoreErrorsIfPathIsInParentDirPath , final boolean ignoreIfNotExecutable ) {
233
- if (path == null || path .isEmpty ()) return context .getString (R .string .null_or_empty_directory );
233
+ if (path == null || path .isEmpty ()) return context .getString (R .string .error_null_or_empty_directory );
234
234
235
235
try {
236
236
File file = new File (path );
237
237
238
238
// If file exits but not a directory file
239
239
if (file .exists () && !file .isDirectory ()) {
240
- return context .getString (R .string .non_directory_file_found );
240
+ return context .getString (R .string .error_non_directory_file_found );
241
241
}
242
242
243
243
boolean isPathInParentDirPath = false ;
@@ -254,7 +254,7 @@ public static String validateDirectoryExistenceAndPermissions(final Context cont
254
254
Logger .logVerbose (LOG_TAG , "Creating missing directory at path: \" " + path + "\" " );
255
255
// If failed to create directory
256
256
if (!file .mkdirs ()) {
257
- return context .getString (R .string .creating_missing_directory_failed , path );
257
+ return context .getString (R .string .error_creating_missing_directory_failed , path );
258
258
}
259
259
}
260
260
@@ -271,7 +271,7 @@ public static String validateDirectoryExistenceAndPermissions(final Context cont
271
271
// If path is not a directory
272
272
// Directories can be automatically created so we can ignore if missing with above check
273
273
if (!file .isDirectory ()) {
274
- return context .getString (R .string .no_directory_found );
274
+ return context .getString (R .string .error_no_directory_found );
275
275
}
276
276
277
277
if (permissionsToCheck != null ) {
@@ -282,7 +282,7 @@ public static String validateDirectoryExistenceAndPermissions(final Context cont
282
282
}
283
283
// Some function calls may throw SecurityException, etc
284
284
catch (Exception e ) {
285
- return context .getString (R .string .validate_directory_existence_and_permissions_failed_with_exception , path , e .getMessage ());
285
+ return context .getString (R .string .error_validate_directory_existence_and_permissions_failed_with_exception , path , e .getMessage ());
286
286
}
287
287
288
288
return null ;
@@ -332,11 +332,11 @@ public static void setMissingFilePermissions(String path, String permissionsToSe
332
332
* @return Returns the {@code errmsg} if validating permissions failed, otherwise {@code null}.
333
333
*/
334
334
public static String checkMissingFilePermissions (Context context , String path , String permissionsToCheck , String fileType , boolean ignoreIfNotExecutable ) {
335
- if (path == null || path .isEmpty ()) return context .getString (R .string .null_or_empty_path );
335
+ if (path == null || path .isEmpty ()) return context .getString (R .string .error_null_or_empty_path );
336
336
337
337
if (!isValidPermissingString (permissionsToCheck )) {
338
338
Logger .logError (LOG_TAG , "Invalid permissionsToCheck passed to checkMissingFilePermissions: \" " + permissionsToCheck + "\" " );
339
- return context .getString (R .string .invalid_file_permissions_string_to_check );
339
+ return context .getString (R .string .error_invalid_file_permissions_string_to_check );
340
340
}
341
341
342
342
if (fileType == null || fileType .isEmpty ()) fileType = "File" ;
@@ -345,17 +345,17 @@ public static String checkMissingFilePermissions(Context context, String path, S
345
345
346
346
// If file is not readable
347
347
if (permissionsToCheck .contains ("r" ) && !file .canRead ()) {
348
- return context .getString (R .string .file_not_readable , fileType );
348
+ return context .getString (R .string .error_file_not_readable , fileType );
349
349
}
350
350
351
351
// If file is not writable
352
352
if (permissionsToCheck .contains ("w" ) && !file .canWrite ()) {
353
- return context .getString (R .string .file_not_writable , fileType );
353
+ return context .getString (R .string .error_file_not_writable , fileType );
354
354
}
355
355
// If file is not executable
356
356
// This canExecute() will give "avc: granted { execute }" warnings for target sdk 29
357
357
else if (permissionsToCheck .contains ("x" ) && !file .canExecute () && !ignoreIfNotExecutable ) {
358
- return context .getString (R .string .file_not_executable , fileType );
358
+ return context .getString (R .string .error_file_not_executable , fileType );
359
359
}
360
360
361
361
return null ;
0 commit comments