2 * ========================================================================
3 * Copyright 2013-2022 Eduardo Chappa
4 * Copyright 2006 University of Washington
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
16 #include "../charconv/utf8.h"
17 #include "../charconv/filesys.h"
18 #include "canaccess.h"
22 /*----------------------------------------------------------------------
23 Check to see if a directory exists and is writable by us
25 Args: dir -- directory name
27 Result: returns 0 if it exists and is writable
28 1 if it is a directory, but is not writable
29 2 if it is not a directory
33 is_writable_dir(char *dir
)
37 if(our_stat(dir
, &sb
) < 0)
38 /*--- It doesn't exist ---*/
41 if(!(sb
.st_mode
& S_IFDIR
))
42 /*---- it's not a directory ---*/
45 if(can_access(dir
, 07))