Beispiel #1
0
    virtual int make_directory(entry_t& entry, const path_t& path) {
        const char_t* chars = 0;
        size_t length = 0;
        int err = 1;

        if ((chars = path.directory().chars(length)) && (0 < length)) {
            const char_t* dchars = chars;
            size_t dlength = length;
            sub_directories_t sub_directories;

            EV_LOG_MESSAGE_INFO("make directory \"" << chars << "\"...");
            for (bool exists = false; !exists; ) {
                string_t directory(dchars, dlength);

                EV_LOG_MESSAGE_INFO("directory \"" << directory.chars() << "\" exists?...");
                if (!(exists = entry.exists(directory.chars()))) {
                    sub_directory_t sub_directory(dchars, dlength);

                    EV_LOG_MESSAGE_INFO("...directory \"" << directory.chars() << "\" does not exist");
                    sub_directories.push_front(sub_directory);
                    if ((dchars = parent_directory(dchars, dlength, path))) {
                        continue;
                    }
                } else {
                    EV_LOG_MESSAGE_INFO("...directory \"" << directory.chars() << "\" exists");
                }
                break;
            }
            err = make_directories(sub_directories, entry, path);
        }
        return err;
    }
Beispiel #2
0
    virtual int copy_file_to_hash
    (const entry_t& source, const path_t& target, hash_t& hash) {
        entry_t& entry = target_entry_;
        string_t target_path(target.chars());
        const char_t* chars = 0;
        int err = 1;

        if ((append_hash_name_to_target_path_) && (chars = hash.name())) {
            target_path.append(&target.extension_separator(), 1);
            target_path.append(hash_name_prefix_);
            target_path.append(chars);
            target_path.append(hash_name_suffix_);
        }

        if ((entry.exists(chars = target_path.chars()))) {
            if ((write_overwrite != write_) && (write_append != write_)) {
                errf("target file \"%s\" already exists\n", chars);
            } else {
                fs::entry_type type = fs::entry_type_none;

                switch (type = entry.type()) {
                case fs::entry_type_file:
                    err = copy_file_to_file_hash(source, entry, hash);
                    break;
                default:
                    break;
                }
            }
        } else {
            if (!(err = make_directory(entry, target))) {
                entry.set_path(chars);
                err = copy_file_to_file_hash(source, entry, hash);
            } else {
                errf("failed to make directory \"%s\"\n", target.directory().chars());
            }
        }
        if (!(err) && (!(to_same != to_) || !(target_modified_))) {
            if ((entry.set_times_to_set(source))) {
                if ((entry.set_times_set())) {
                } else {
                }
            }
        }
        return err;
    }
Beispiel #3
0
    virtual int copy_file(const entry_t& source, const path_t& target) {
        entry_t& entry = target_entry_;
        const char_t* chars = 0;
        int err = 1;

        if ((entry.exists(chars = target.chars()))) {
            if ((write_overwrite != write_) && (write_append != write_)) {
                errf("target file \"%s\" already exists\n", chars);
            } else {
                fs::entry_type type = fs::entry_type_none;

                switch (type = entry.type()) {
                case fs::entry_type_file:
                    err = copy_file_to_file(source, entry);
                    break;
                default:
                    break;
                }
            }
        } else {
            if (!(err = make_directory(entry, target))) {
                entry.set_path(chars);
                err = copy_file_to_file(source, entry);
            } else {
                errf("failed to make directory \"%s\"\n", target.directory().chars());
            }
        }
        if (!(err) && (!(to_same != to_) || !(target_modified_))) {
            if ((entry.set_times_to_set(source))) {
                if ((entry.set_times_set())) {
                } else {
                }
            }
        }
        return err;
    }