@@ -116,6 +116,11 @@ def read(self, path):
116116
117117 return None
118118
119+ def exists (self , path : str ) -> bool :
120+ try :
121+ return os .path .exists (path )
122+ except OSError :
123+ return False
119124
120125class Remotehost (Localhost ):
121126 def __init__ (self , prefix , capdir ):
@@ -159,6 +164,18 @@ def run(self, cmd, default=None, log=True):
159164
160165 return out
161166
167+ def exists (self , path : str ) -> bool :
168+ if not self ._run (("ls" , path ), default = "" , log = False ):
169+ return False
170+
171+ if self .capdir :
172+ dirname = os .path .join (self .capdir , "rootfs" , os .path .dirname (path [1 :]))
173+ filname = os .path .join (self .capdir , "rootfs" , path [1 :])
174+ os .makedirs (dirname , exist_ok = True )
175+ open (filname , "w" , encoding = 'utf-8' ).close () # Create empty file
176+
177+ return True
178+
162179 def read (self , path ):
163180 out = self ._run (("cat" , path ), default = "" , log = False )
164181
@@ -199,6 +216,13 @@ def run(self, cmd, default=None, log=True):
199216 common .LOG .error (f"No recording found for run \" { path } \" " )
200217 raise
201218
219+ def exists (self , path : str ) -> bool :
220+ path = os .path .join (self .replaydir , "rootfs" , path [1 :])
221+ try :
222+ return os .path .exists (path )
223+ except OSError :
224+ return False
225+
202226 def read (self , path ):
203227 path = os .path .join (self .replaydir , "rootfs" , path [1 :])
204228 try :
0 commit comments