295 win32file.SetFilePointer(self.handle, int(pos), |
295 win32file.SetFilePointer(self.handle, int(pos), |
296 win32file.FILE_BEGIN) |
296 win32file.FILE_BEGIN) |
297 win32file.SetEndOfFile(self.handle) |
297 win32file.SetEndOfFile(self.handle) |
298 except pywintypes.error, err: |
298 except pywintypes.error, err: |
299 raise WinIOError(err) |
299 raise WinIOError(err) |
|
300 |
|
301 def find_in_path(name, path, default=None): |
|
302 '''find name in search path. path can be string (will be split |
|
303 with os.pathsep), or iterable thing that returns strings. if name |
|
304 found, return path to name. else return default. name is looked up |
|
305 using cmd.exe rules, using PATHEXT.''' |
|
306 if isinstance(path, str): |
|
307 path = path.split(os.pathsep) |
|
308 |
|
309 pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD') |
|
310 pathext = pathext.lower().split(os.pathsep) |
|
311 isexec = os.path.splitext(name)[1].lower() in pathext |
|
312 |
|
313 for p in path: |
|
314 p_name = os.path.join(p, name) |
|
315 |
|
316 if isexec and os.path.exists(p_name): |
|
317 return p_name |
|
318 |
|
319 for ext in pathext: |
|
320 p_name_ext = p_name + ext |
|
321 if os.path.exists(p_name_ext): |
|
322 return p_name_ext |
|
323 |
|
324 return default |
300 |
325 |
301 getuser_fallback = win32api.GetUserName |
326 getuser_fallback = win32api.GetUserName |