Changeset 6150

Show
Ignore:
Timestamp:
09/22/08 16:41:12 (4 months ago)
Author:
morris
Message:

Update for libwired

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/P7/wired/wired/files.c

    r6141 r6150  
    183183        if(!fsenumerator) { 
    184184                wi_log_warn(WI_STR("Could not open %@: %m"), realpath); 
    185                 wd_user_reply_errno(user, message); 
     185                wd_user_reply_file_errno(user, message); 
    186186                 
    187187                return; 
     
    214214                        wi_string_insert_string_at_index(virtualpath, path, 0); 
    215215                 
    216                 alias = wi_fs_is_alias(filepath); 
     216                alias = wi_fs_path_is_alias(filepath); 
    217217                 
    218218                if(alias) 
     
    221221                        resolvedpath = filepath; 
    222222 
    223                 if(!wi_fs_lstat(resolvedpath, &lsb)) { 
     223                if(!wi_fs_lstat_path(resolvedpath, &lsb)) { 
    224224                        wi_log_warn(WI_STR("Could not list %@: %m"), resolvedpath); 
    225225 
     
    227227                } 
    228228 
    229                 if(!wi_fs_stat(resolvedpath, &sb)) 
     229                if(!wi_fs_stat_path(resolvedpath, &sb)) 
    230230                        sb = lsb; 
    231231 
     
    279279                upload = false; 
    280280 
    281         if(upload && wi_fs_statfs(realpath, &sfb)) 
     281        if(upload && wi_fs_statfs_path(realpath, &sfb)) 
    282282                available = (wi_file_offset_t) sfb.bavail * (wi_file_offset_t) sfb.frsize; 
    283283        else 
     
    304304                 
    305305                if(user) 
    306                         wd_user_reply_errno(user, message); 
     306                        wd_user_reply_file_errno(user, message); 
    307307                 
    308308                return 0; 
     
    334334         
    335335        realpath = wd_files_real_path(path, user); 
    336         alias = wi_fs_is_alias(realpath); 
     336        alias = wi_fs_path_is_alias(realpath); 
    337337         
    338338        if(alias) 
    339339                wi_string_resolve_aliases_in_path(realpath); 
    340340 
    341         if(!wi_fs_lstat(realpath, &lsb)) { 
     341        if(!wi_fs_lstat_path(realpath, &lsb)) { 
    342342                wi_log_warn(WI_STR("Could not read info for %@: %m"), realpath); 
    343                 wd_user_reply_errno(user, message); 
     343                wd_user_reply_file_errno(user, message); 
    344344                 
    345345                return; 
    346346        } 
    347347         
    348         if(!wi_fs_stat(realpath, &sb)) 
     348        if(!wi_fs_stat_path(realpath, &sb)) 
    349349                sb = lsb; 
    350350 
     
    413413        if(!wi_fs_create_directory(realpath, 0777)) { 
    414414                wi_log_warn(WI_STR("Could not create %@: %m"), realpath); 
    415                 wd_user_reply_errno(user, message); 
     415                wd_user_reply_file_errno(user, message); 
    416416 
    417417                return false; 
     
    437437        wi_string_append_path_component(realpath, component); 
    438438         
    439         result = wi_fs_delete(realpath); 
     439        result = wi_fs_delete_path(realpath); 
    440440         
    441441        if(result) { 
     
    443443        } else { 
    444444                wi_log_warn(WI_STR("Could not delete %@: %m"), realpath); 
    445                 wd_user_reply_errno(user, message); 
     445                wd_user_reply_file_errno(user, message); 
    446446        } 
    447447         
     
    469469        wi_string_append_path_component(realtopath, realtoname); 
    470470         
    471         if(!wi_fs_lstat(realfrompath, &sb)) { 
     471        if(!wi_fs_lstat_path(realfrompath, &sb)) { 
    472472                wi_log_warn(WI_STR("Could not rename %@: %m"), realfrompath); 
    473                 wd_user_reply_errno(user, message); 
     473                wd_user_reply_file_errno(user, message); 
    474474 
    475475                return false; 
     
    483483                 
    484484                if(path) { 
    485                         result = wi_fs_rename(realfrompath, path); 
     485                        result = wi_fs_rename_path(realfrompath, path); 
    486486                 
    487487                        if(result) 
    488                                 result = wi_fs_rename(path, realtopath); 
     488                                result = wi_fs_rename_path(path, realtopath); 
    489489                } 
    490490        } else { 
    491                 if(wi_fs_lstat(realtopath, &sb)) { 
     491                if(wi_fs_lstat_path(realtopath, &sb)) { 
    492492                        wd_user_reply_error(user, WI_STR("wired.error.file_exists"), message); 
    493493 
     
    495495                } 
    496496                 
    497                 result = wi_fs_rename(realfrompath, realtopath); 
     497                result = wi_fs_rename_path(realfrompath, realtopath); 
    498498        } 
    499499         
     
    520520                        wi_log_warn(WI_STR("Could not rename %@ to %@: %m"), 
    521521                                realfrompath, realtopath); 
    522                         wd_user_reply_errno(user, message); 
     522                        wd_user_reply_file_errno(user, message); 
    523523                } 
    524524        } 
     
    540540        realtopath              = WI_ARRAY(array, 3); 
    541541         
    542         if(wi_fs_copy(realfrompath, realtopath)) { 
    543                 if(wi_fs_delete(realfrompath)) 
     542        if(wi_fs_copy_path(realfrompath, realtopath)) { 
     543                if(wi_fs_delete_path(realfrompath)) 
    544544                        wd_files_move_comment(frompath, topath, NULL, NULL); 
    545545                else 
     
    569569        wi_string_append_path_component(realfrompath, realfromname); 
    570570         
    571         if(!wi_fs_lstat(realfrompath, &sb)) { 
     571        if(!wi_fs_lstat_path(realfrompath, &sb)) { 
    572572                wi_log_warn(WI_STR("Could not link %@: %m"), realfrompath); 
    573                 wd_user_reply_errno(user, message); 
     573                wd_user_reply_file_errno(user, message); 
    574574 
    575575                return false; 
    576576        } 
    577577 
    578         if(wi_fs_lstat(realtopath, &sb)) { 
     578        if(wi_fs_lstat_path(realtopath, &sb)) { 
    579579                wd_user_reply_error(user, WI_STR("wired.error.file_exists"), message); 
    580580 
     
    582582        } 
    583583         
    584         if(!wi_fs_symlink(realfrompath, realtopath)) { 
    585                 wd_user_reply_errno(user, message); 
     584        if(!wi_fs_symlink_path(realfrompath, realtopath)) { 
     585                wd_user_reply_file_errno(user, message); 
    586586                 
    587587                return false; 
     
    611611        if(!file) { 
    612612                wi_log_warn(WI_STR("Could not open %@: %m"), wd_files_index_path); 
    613                 wd_user_reply_errno(user, message); 
     613                wd_user_reply_file_errno(user, message); 
    614614 
    615615                goto end; 
     
    685685         
    686686        if(!force) { 
    687                 if(wi_fs_stat(wd_files_index_path, &sb)) { 
     687                if(wi_fs_stat_path(wd_files_index_path, &sb)) { 
    688688                        interval = wi_date_time_interval_since_now(wi_date_with_time(sb.mtime)); 
    689689                        index_time  = (wd_files_index_time > 0.0) ? wd_files_index_time : 3600.0; 
     
    795795                        wi_rwlock_wrlock(wd_files_index_lock); 
    796796                         
    797                         if(wi_fs_rename(path, wd_files_index_path)) { 
     797                        if(wi_fs_rename_path(path, wd_files_index_path)) { 
    798798                                wi_log_info(WI_STR("Indexed %u %s and %u %s for a total of %llu %s in %.2f seconds"), 
    799799                                        wd_files_count, 
     
    875875                } 
    876876 
    877                 alias = wi_fs_is_alias(filepath); 
     877                alias = wi_fs_path_is_alias(filepath); 
    878878                 
    879879                if(alias) 
     
    882882                        resolvedpath = filepath; 
    883883                 
    884                 if(!wi_fs_lstat(resolvedpath, &lsb)) { 
     884                if(!wi_fs_lstat_path(resolvedpath, &lsb)) { 
    885885                        wi_log_warn(WI_STR("Skipping index of %@: %m"), resolvedpath); 
    886886                        wi_fsenumerator_skip_descendents(fsenumerator); 
    887887                } else { 
    888                         if(!wi_fs_stat(resolvedpath, &sb)) 
     888                        if(!wi_fs_stat_path(resolvedpath, &sb)) 
    889889                                sb = lsb; 
    890890                         
     
    10961096        wi_fs_stat_t    sb; 
    10971097         
    1098         if(!wi_fs_stat(path, &sb)) { 
     1098        if(!wi_fs_stat_path(path, &sb)) { 
    10991099                wi_log_warn(WI_STR("Could not read type for %@: %m"), path); 
    11001100                 
     
    11171117        typepath = wi_string_by_appending_path_component(realpath, WI_STR(WD_FILES_META_TYPE_PATH)); 
    11181118         
    1119         if(!wi_fs_stat(typepath, &sb) || sb.size > 8) 
     1119        if(!wi_fs_stat_path(typepath, &sb) || sb.size > 8) 
    11201120                return WD_FILE_TYPE_DIR; 
    11211121         
     
    11481148                        if(wi_error_code() != EEXIST) { 
    11491149                                wi_log_warn(WI_STR("Could not create %@: %m"), metapath); 
    1150                                 wd_user_reply_errno(user, message); 
     1150                                wd_user_reply_file_errno(user, message); 
    11511151 
    11521152                                return; 
     
    11561156                if(!wi_string_write_to_file(wi_string_with_format(WI_STR("%u\n"), type), typepath)) { 
    11571157                        wi_log_warn(WI_STR("Could not write to %@: %m"), typepath); 
    1158                         wd_user_reply_errno(user, message); 
     1158                        wd_user_reply_file_errno(user, message); 
    11591159                } 
    11601160        } else { 
    1161                 if(wi_fs_delete(typepath)) 
     1161                if(wi_fs_delete_path(typepath)) 
    11621162                        (void) rmdir(wi_string_cstring(metapath)); 
    11631163        } 
     
    11731173        realpath = wi_string_by_resolving_aliases_in_path(wd_files_real_path(path, user)); 
    11741174         
    1175         if(!wi_fs_set_mode(realpath, executable ? 0755 : 0644)) { 
     1175        if(!wi_fs_set_mode_for_path(realpath, executable ? 0755 : 0644)) { 
    11761176                wi_log_warn(WI_STR("Could not set mode for %@: %m"), realpath); 
    1177                 wd_user_reply_errno(user, message); 
     1177                wd_user_reply_file_errno(user, message); 
    11781178        } 
    11791179} 
     
    11931193#ifdef HAVE_CORESERVICES_CORESERVICES_H 
    11941194        realpath        = wi_string_by_resolving_aliases_in_path(wd_files_real_path(path, user)); 
    1195         comment         = wi_fs_finder_comment(realpath); 
     1195        comment         = wi_fs_finder_comment_for_path(realpath); 
    11961196         
    11971197        if(comment) 
     
    12391239                                 
    12401240                                if(user) 
    1241                                         wd_user_reply_errno(user, message); 
     1241                                        wd_user_reply_file_errno(user, message); 
    12421242                                 
    12431243                                return; 
     
    12571257                 
    12581258                if(user) 
    1259                         wd_user_reply_errno(user, message); 
     1259                        wd_user_reply_file_errno(user, message); 
    12601260 
    12611261                return; 
     
    12921292                wi_file_close(tmpfile); 
    12931293                 
    1294                 if(wi_fs_delete(commentpath)) 
     1294                if(wi_fs_delete_path(commentpath)) 
    12951295                        (void) rmdir(wi_string_cstring(metapath)); 
    12961296        } 
     
    12991299        realpath = wi_string_by_resolving_aliases_in_path(wd_files_real_path(path, user)); 
    13001300 
    1301         if(wi_fs_exists(realpath, NULL)) { 
    1302                 if(!wi_fs_set_finder_comment(realpath, comment)) 
    1303                         wi_log_info(WI_STR("Could not set Finder comment: %m")); 
     1301        if(wi_fs_path_exists(realpath, NULL)) { 
     1302                if(!wi_fs_set_finder_comment_for_path(realpath, comment)) 
     1303                        wi_log_err(WI_STR("Could not set Finder comment: %m")); 
    13041304        } 
    13051305#endif 
     
    13581358        permissionspath = wi_string_by_appending_path_component(realpath, WI_STR(WD_FILES_META_PERMISSIONS_PATH)); 
    13591359         
    1360         if(!wi_fs_stat(permissionspath, &sb) || sb.size > 128) 
     1360        if(!wi_fs_stat_path(permissionspath, &sb) || sb.size > 128) 
    13611361                return false; 
    13621362         
     
    13941394                        if(wi_error_code() != EEXIST) { 
    13951395                                wi_log_warn(WI_STR("Could not create %@: %m"), metapath); 
    1396                                 wd_user_reply_errno(user, message); 
     1396                                wd_user_reply_file_errno(user, message); 
    13971397 
    13981398                                return; 
     
    14071407                if(!wi_string_write_to_file(string, permissionspath)) { 
    14081408                        wi_log_warn(WI_STR("Could not write to %@: %m"), permissionspath); 
    1409                         wd_user_reply_errno(user, message); 
     1409                        wd_user_reply_file_errno(user, message); 
    14101410                } 
    14111411        } else { 
    1412                 if(wi_fs_delete(permissionspath)) 
     1412                if(wi_fs_delete_path(permissionspath)) 
    14131413                        (void) rmdir(wi_string_cstring(metapath)); 
    14141414        } 
  • branches/P7/wired/wired/main.c

    r6130 r6150  
    345345        path = WI_STR("wired.pid"); 
    346346 
    347         if(!wi_fs_delete(path)) 
     347        if(!wi_fs_delete_path(path)) 
    348348                wi_log_warn(WI_STR("Could not delete %@: %m"), path); 
    349349} 
     
    396396        path = WI_STR("wired.status"); 
    397397 
    398         if(!wi_fs_delete(path)) 
     398        if(!wi_fs_delete_path(path)) 
    399399                wi_log_warn(WI_STR("Could not delete %@: %m"), path); 
    400400} 
  • branches/P7/wired/wired/news.c

    r6130 r6150  
    169169        wi_rwlock_wrlock(wd_news_lock); 
    170170 
    171         if(!wi_fs_clear(wd_news_path)) 
     171        if(!wi_fs_clear_path(wd_news_path)) 
    172172                wi_log_err(WI_STR("Could not clear %@: %m"), wd_news_path); 
    173173 
  • branches/P7/wired/wired/server.c

    r6122 r6150  
    544544 
    545545 
    546 void wd_user_reply_errno(wd_user_t *user, wi_p7_message_t *message) { 
     546void wd_user_reply_file_errno(wd_user_t *user, wi_p7_message_t *message) { 
    547547        wi_p7_message_t         *reply; 
    548548        int                                     code; 
     
    556556                        wd_user_reply_error(user, WI_STR("wired.error.file_exists"), message); 
    557557        } else { 
    558                 reply = wi_p7_message_with_name(WI_STR("wired.error"), wd_p7_spec); 
    559                 wi_p7_message_set_enum_name_for_name(reply, WI_STR("wired.error.internal_error"), WI_STR("wired.error")); 
    560                 wi_p7_message_set_string_for_name(reply, wi_error_string(), WI_STR("wired.error.string")); 
    561                 wd_user_reply_message(user, reply, message); 
    562         } 
     558                wd_user_reply_internal_error(user, message); 
     559        } 
     560
     561 
     562 
     563 
     564void wd_user_reply_internal_error(wd_user_t *user, wi_p7_message_t *message) { 
     565        wi_p7_message_t         *reply; 
     566         
     567        reply = wi_p7_message_with_name(WI_STR("wired.error"), wd_p7_spec); 
     568        wi_p7_message_set_enum_name_for_name(reply, WI_STR("wired.error.internal_error"), WI_STR("wired.error")); 
     569        wi_p7_message_set_string_for_name(reply, wi_error_string(), WI_STR("wired.error.string")); 
     570        wd_user_reply_message(user, reply, message); 
    563571} 
    564572 
  • branches/P7/wired/wired/server.h

    r5627 r6150  
    4949void                                                            wd_user_reply_message(wd_user_t *, wi_p7_message_t *, wi_p7_message_t *); 
    5050void                                                            wd_user_reply_error(wd_user_t *, wi_string_t *, wi_p7_message_t *); 
    51 void                                                            wd_user_reply_errno(wd_user_t *, wi_p7_message_t *); 
     51void                                                            wd_user_reply_file_errno(wd_user_t *, wi_p7_message_t *); 
     52void                                                            wd_user_reply_internal_error(wd_user_t *, wi_p7_message_t *); 
    5253void                                                            wd_broadcast_message(wi_p7_message_t *); 
    5354void                                                            wd_chat_broadcast_message(wd_chat_t *chat, wi_p7_message_t *); 
  • branches/P7/wired/wired/transfers.c

    r6130 r6150  
    217217        realpath = wi_string_by_resolving_aliases_in_path(wd_files_real_path(path, user)); 
    218218         
    219         if(!wi_fs_stat(realpath, &sb)) { 
     219        if(!wi_fs_stat_path(realpath, &sb)) { 
    220220                wi_log_err(WI_STR("Could not open %@: %m"), realpath); 
    221                 wd_user_reply_errno(user, message); 
     221                wd_user_reply_file_errno(user, message); 
    222222 
    223223                return; 
     
    264264        realpath = wi_string_by_resolving_aliases_in_path(wd_files_real_path(path, user)); 
    265265         
    266         if(wi_fs_stat(realpath, &sb)) { 
    267                 wd_user_reply_errno(user, message); 
     266        if(wi_fs_stat_path(realpath, &sb)) { 
     267                wd_user_reply_file_errno(user, message); 
    268268 
    269269                return; 
     
    273273                wi_string_append_string(realpath, WI_STR(WD_TRANSFERS_PARTIAL_EXTENSION)); 
    274274         
    275         if(wi_fs_stat(realpath, &sb)) 
     275        if(wi_fs_stat_path(realpath, &sb)) 
    276276                offset = sb.size; 
    277277        else 
     
    10171017                path = wi_string_by_deleting_path_extension(transfer->realpath); 
    10181018 
    1019                 if(wi_fs_rename(transfer->realpath, path)) { 
     1019                if(wi_fs_rename_path(transfer->realpath, path)) { 
    10201020                        if(transfer->executable) { 
    1021                                 if(!wi_fs_set_mode(path, 0755)) { 
     1021                                if(!wi_fs_set_mode_for_path(path, 0755)) { 
    10221022                                        wi_log_warn(WI_STR("Could not set mode for %@: %m"), 
    10231023                                                path);