1717from pyfatfs .errors import DirectoryExpected , \
1818 FileExpected , DirectoryNotEmpty , RemoveRootError , \
1919 FileExists
20+ from pyfatfs ._exceptions import PyFATException
2021
2122from pyfatfs import FAT_OEM_ENCODING
2223from pyfatfs .DosDateTime import DosDateTime
@@ -408,7 +409,7 @@ def removetree(self, dir_path: str):
408409 except RemoveRootError :
409410 pass
410411
411- def remove (self , path : str ):
412+ def _rm_file_check (self , path : str ):
412413 """Remove a file from the filesystem.
413414
414415 :param path: `str`: Path of file to remove
@@ -422,6 +423,19 @@ def remove(self, path: str):
422423 base = dir_entry .get_parent_dir ()
423424 self ._remove (base , dir_entry )
424425
426+ def rm_file (self , path ):
427+ """Remove a file from the filesystem.
428+
429+ :param path: `str`: Path of file to remove
430+ """
431+ dir_entry = self ._get_dir_entry (path )
432+ try :
433+ base = dir_entry .get_parent_dir ()
434+ except PyFATException :
435+ # Cannot query parent directory of root directory
436+ return
437+ self ._remove (base , dir_entry )
438+
425439 def _remove (self , parent_dir : FATDirectoryEntry ,
426440 dir_entry : FATDirectoryEntry ):
427441 """Remove directory entry regardless of type (dir or file).
0 commit comments