+ if (oacp_create) {
+ struct stat st;
+
+ fp = fopen(new_abs_filepath, "a");
+ if (!fp) {
+ BT_DBG("fopen() failed : %s", strerror(errno));
+ ret = BLUETOOTH_ATT_ERROR_INTERNAL;
+ goto fail;
+ }
+
+ if (stat(new_abs_filepath, &st) == -1) {
+ BT_INFO("stat failed: (%d)\n", errno);
+ ret = BLUETOOTH_ATT_ERROR_INTERNAL;
+ goto fail;
+ }
+
+ object->name = g_strdup(filename);
+ object->first_created = st.st_ctime;
+ object->last_modified = st.st_ctime;
+ object->curr_size = (uint32_t) st.st_size;
+ oacp_create = FALSE;
+ } else {
+ char old_abs_filepath[BT_FILE_PATH_MAX_LEN] = {0, };
+ snprintf(old_abs_filepath, BT_FILE_PATH_MAX_LEN, "%s%s",
+ directory, object->name);
+
+ if (rename(old_abs_filepath, new_abs_filepath)) {
+ ret = BLUETOOTH_ATT_ERROR_INTERNAL;
+ goto fail;
+ }
+ }
+