this repo has no description
at trunk 33 lines 854 B view raw
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) 2#include <fcntl.h> 3#include <sys/stat.h> 4#include <unistd.h> 5 6#include <cerrno> 7 8#include "builtins.h" 9#include "file.h" 10#include "frame.h" 11#include "handles.h" 12#include "module-builtins.h" 13#include "modules.h" 14#include "os.h" 15#include "symbols.h" 16 17namespace py { 18 19RawObject FUNC(_path, isdir)(Thread*, Arguments args) { 20 CHECK(args.get(0).isStr(), "path must be str"); 21 unique_c_ptr<char> path(Str::cast(args.get(0)).toCStr()); 22 bool result = OS::dirExists(path.get()); 23 return Bool::fromBool(result); 24} 25 26RawObject FUNC(_path, isfile)(Thread*, Arguments args) { 27 CHECK(args.get(0).isStr(), "path must be str"); 28 unique_c_ptr<char> path(Str::cast(args.get(0)).toCStr()); 29 bool result = OS::fileExists(path.get()); 30 return Bool::fromBool(result); 31} 32 33} // namespace py