1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: writ_dir.c 761 2007-10-23 22:35:18Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2013-2020 Eduardo Chappa
8 * Copyright 2006 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
20 #include "../charconv/utf8.h"
21 #include "../charconv/filesys.h"
22 #include "canaccess.h"
26 /*----------------------------------------------------------------------
27 Check to see if a directory exists and is writable by us
29 Args: dir -- directory name
31 Result: returns 0 if it exists and is writable
32 1 if it is a directory, but is not writable
33 2 if it is not a directory
37 is_writable_dir(char *dir
)
41 if(our_stat(dir
, &sb
) < 0)
42 /*--- It doesn't exist ---*/
45 if(!(sb
.st_mode
& S_IFDIR
))
46 /*---- it's not a directory ---*/
49 if(can_access(dir
, 07))