* mechanism to avoid this is to store leaf object names with an
* object locator w/o trailing slash */
- /* mutating path */
- std::string obj_path{parent->relative_object_name()};
- if ((obj_path.length() > 0) &&
- (obj_path.back() != '/'))
- obj_path += "/";
- obj_path += path;
+ std::string obj_path = parent->format_child_name(path, false);
for (auto ix : { 0, 1, 2 }) {
switch (ix) {
} else {
/* create an object representing the directory */
buffer::list bl;
- string dir_name = /* XXX get rid of this some day soon, too */
- parent->relative_object_name();
-
- /* creating objects w/leading '/' makes a mess */
- if ((dir_name.size() > 0) &&
- (dir_name.back() != '/'))
- dir_name += "/";
- dir_name += name;
- dir_name += "/";
+ string dir_name = parent->format_child_name(name, true);
/* need valid S3 name (characters, length <= 1024, etc) */
rc = valid_fs_object_name(dir_name);
}
/* expand and check name */
- std::string obj_name{parent->relative_object_name()};
- if ((obj_name.size() > 0) &&
- (obj_name.back() != '/'))
- obj_name += "/";
- obj_name += name;
+ std::string obj_name = parent->format_child_name(name, false);
rc = valid_fs_object_name(obj_name);
if (rc != 0) {
return MkObjResult{nullptr, rc};
return full_object_name(true /* omit_bucket */);
}
- inline std::string format_child_name(const std::string& cbasename) const {
+ inline std::string format_child_name(const std::string& cbasename,
+ bool is_dir) const {
std::string child_name{relative_object_name()};
if ((child_name.size() > 0) &&
(child_name.back() != '/'))
child_name += "/";
child_name += cbasename;
+ if (is_dir)
+ child_name += "/";
return child_name;
}
src_bucket_name = src_parent->bucket_name();
// need s->src_bucket_name?
- src_object.name = src_parent->format_child_name(src_name);
+ src_object.name = src_parent->format_child_name(src_name, false);
// need s->src_object?
dest_bucket_name = dst_parent->bucket_name();
// need s->bucket.name?
- dest_object = dst_parent->format_child_name(dst_name);
+ dest_object = dst_parent->format_child_name(dst_name, false);
// need s->object_name?
int rc = valid_s3_object_name(dest_object);