@@ -183,6 +183,9 @@ bool Path::is_absolute () const
183183// //////////////////////////////////////////////////////////////////////////////
184184bool Path::is_link () const
185185{
186+ if (! exists ())
187+ return false ;
188+
186189 struct stat s {};
187190 if (lstat (_data.c_str (), &s))
188191 throw format (" lstat error {1}: {2}" , errno, strerror (errno));
@@ -195,6 +198,9 @@ bool Path::is_link () const
195198// to determine.
196199bool Path::readable () const
197200{
201+ if (! exists ())
202+ return false ;
203+
198204 auto status = access (_data.c_str (), R_OK);
199205 if (status == -1 && errno != EACCES)
200206 throw format (" access error {1}: {2}" , errno, strerror (errno));
@@ -207,6 +213,9 @@ bool Path::readable () const
207213// to determine.
208214bool Path::writable () const
209215{
216+ if (! exists ())
217+ return false ;
218+
210219 auto status = access (_data.c_str (), W_OK);
211220 if (status == -1 && errno != EACCES)
212221 throw format (" access error {1}: {2}" , errno, strerror (errno));
@@ -219,6 +228,9 @@ bool Path::writable () const
219228// to determine.
220229bool Path::executable () const
221230{
231+ if (! exists ())
232+ return false ;
233+
222234 auto status = access (_data.c_str (), X_OK);
223235 if (status == -1 && errno != EACCES)
224236 throw format (" access error {1}: {2}" , errno, strerror (errno));
0 commit comments