-static bool _net_nfc_emul_controller_create_interfaceFile (void)
-{
- char file_name[1024] = { 0, };
- FILE *fp = NULL;
- struct stat st;
- bool retval = false;
-
- DEBUG_EMUL_BEGIN();
-
- /* create folder */
- if (stat(NET_NFC_EMUL_DATA_PATH, &st) != 0){
- if(mkdir(NET_NFC_EMUL_DATA_PATH, 0777) != 0){
- DEBUG_MSG("create folder is failed");
- return false;
- }
- }
- else{
- DEBUG_MSG("folder is already created");
- }
-
- /* create file */
- snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_EMUL_DATA_PATH, NET_NFC_EMUL_MESSAGE_FILE_NAME );
- SECURE_LOGD("file path : %s", file_name);
-
- if (stat(file_name, &st) == 0) {
- DEBUG_MSG("file is already created");
- return true;
- }
-
- if ((fp = fopen(file_name, "w")) != NULL)
- {
- struct passwd *pw_root = NULL;
- struct group *gr_root = NULL;
-
- fchmod(fileno(fp), 0755);
-
- pw_root = getpwnam("root");
- gr_root = getgrnam("root");
-
- if ((pw_root != NULL) && (gr_root != NULL))
- {
- if (fchown(fileno(fp), pw_root->pw_uid, gr_root->gr_gid) < 0)
- {
- DEBUG_ERR_MSG("failed to change owner");
- }
- else {
- retval = true;
- }
- }
- else {
- DEBUG_ERR_MSG("failed to get privilege");
- }
-
- fclose(fp);
-
- }
- else {
- DEBUG_ERR_MSG("failed to create file");
- }
-
- DEBUG_EMUL_END();
-
- return retval;
-}
-