4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jungmin Cho <chivalry.cho@samsung.com>, Gwangho Hwang <gwang.hwang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
29 static int recurse(const char *path, mode_t mode, int (*fn)(const char *,mode_t, int)) {
36 if (lstat (path, &st) == -1) {
39 if (strrchr(path, '/') != NULL) {
40 int n = strlen(path)-strlen(strrchr(path, '/'));
44 strncpy(dir, path, n);
52 int dlp_chmod(const char *path, mode_t mode, int recursive) {
53 #ifdef HAVE_WIN32_PROC
54 fprintf(stderr, "error: dlp_chmod not implemented on Win32 (%s)\n", path);
59 if (stat (path, &st) == -1)
62 if (chmod (path, mode) == -1) {
66 return recurse(path, mode, dlp_chmod);