#include <unistd.h>
#include <mm_file.h>
-#include "mm_file_traverse.h"
#include "mm_file_debug.h"
static FILE *msg_tmp_fp = NULL;
int ret = lstat(argv[1], &statbuf);
if (ret < 0) {
printf("lstat error[%d]\n", ret);
- return MMFILE_FAIL;
+ return -1;
}
- if (fpFailList == NULL) {
+ if (fpFailList == NULL)
fpFailList = fopen("/opt/var/log/mmfile_fails.txt", "w");
- }
- if (S_ISDIR(statbuf.st_mode)) {
- mmfile_get_file_names(argv[1], mmfile_get_file_infomation, NULL);
- } else {
- if (argv[2] == NULL)
- mmfile_get_file_infomation(argv[1], NULL, file_test);
- else
- mmfile_get_video_frame(argv[1], argv[2], file_test);
- }
+ if (argv[2] == NULL)
+ mmfile_get_file_infomation(argv[1], NULL, file_test);
+ else
+ mmfile_get_video_frame(argv[1], argv[2], file_test);
if (fpFailList != NULL) {
fflush(fpFailList);
+++ /dev/null
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _MM_FILE_TRAVERSE_H_
-#define _MM_FILE_TRAVERSE_H_
-
-#define MMFILE_PATH_MAX 4096
-
-typedef enum {
- MMFILE_FAIL = 0,
- MMFILE_SUCCESS
-} MMFILE_RETURN;
-
-#define SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
-
-typedef int (*MMFunc)(void *data, void *user_data, bool file_test);
-
-int mmfile_get_file_names(char *root_dir, MMFunc cbfunc, void *user_data);
-
-#endif /* _MM_FILE_TRAVERSE_H_ */
+++ /dev/null
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <glib.h>
-
-#include "mm_file_traverse.h"
-
-int mmfile_get_file_names(char *root_dir, MMFunc cbfunc, void *user_data)
-{
- GDir *dir = NULL;
- GError *error = NULL;
- GArray *dir_array = NULL;
- const char *name;
- char pdirname[MMFILE_PATH_MAX + 1] = {0, };
- char *current_path = NULL;
- char *start_path = NULL;
- char *tmp_path = NULL;
-
- if (!g_file_test(root_dir, G_FILE_TEST_IS_DIR)) {
- printf("it is not directory\n");
- return MMFILE_FAIL;
- }
-
- dir_array = g_array_new(false, false, sizeof(char*));
- if (dir_array == NULL) {
- printf("g_array_new failed");
- return MMFILE_FAIL;
- }
-
- start_path = g_strdup(root_dir);
- if (start_path != NULL)
- g_array_append_val(dir_array, start_path);
-
- while (dir_array->len != 0) {
- current_path = g_array_index(dir_array , char*, 0);
- g_array_remove_index(dir_array, 0);
-
- dir = g_dir_open(current_path, 0, &error);
- if (dir != NULL && error == NULL) {
- while ((name = g_dir_read_name(dir))) {
- memset(pdirname, 0, sizeof(pdirname));
- snprintf(pdirname, sizeof(pdirname), "%s/%s", current_path, name);
-
- if (g_file_test(pdirname, G_FILE_TEST_IS_DIR)) {
- tmp_path = g_strdup(pdirname);
- g_array_append_val(dir_array, tmp_path);
- } else if (g_file_test(pdirname, G_FILE_TEST_IS_REGULAR)) {
- if (cbfunc != NULL)
- cbfunc(pdirname, user_data, true);
- }
- }
- } else {
- printf("g_dir_open failed");
- }
-
- if (dir)
- g_dir_close(dir);
-
- SAFE_FREE(current_path);
- }
-
- if (dir_array)
- g_array_free(dir_array, FALSE);
-
- return MMFILE_SUCCESS;
-}
-