[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH] cp: Kopieren mit Verzeichnis als Ziel gefixt.
---
trunk/src/modules/c/shell/cmds/cp.c | 14 +++-----------
1 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/trunk/src/modules/c/shell/cmds/cp.c b/trunk/src/modules/c/shell/cmds/cp.c
index 0d66eaf..8fb4435 100644
--- a/trunk/src/modules/c/shell/cmds/cp.c
+++ b/trunk/src/modules/c/shell/cmds/cp.c
@@ -1,8 +1,8 @@
/*
- * Copyright (c) 2007 The tyndur Project. All rights reserved.
+ * Copyright (c) 2007-2009 The tyndur Project. All rights reserved.
*
* This code is derived from software contributed to the tyndur Project
- * by Kevin Wolf.
+ * by Kevin Wolf, Alexander Siol
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -229,15 +229,7 @@ int cp_file(char* src_path, char* dst_path) {
FILE* dst = NULL;
if (is_directory(dst_path)) {
char* filename = io_split_filename(src_path);
- size_t length = strlen(filename) + strlen(dst_path) + 1;
-
- char dst_file_path[length + 1];
- strcpy(dst_file_path, dst_path);
- dst_file_path[strlen(dst_file_path) + 1] = '\0';
- dst_file_path[strlen(dst_file_path)] = '/';
- strcat(dst_file_path, filename);
- dst_file_path[length] = '\0';
- dst_path = dst_file_path;
+ asprintf(&dst_path, "%s/%s", dst_path, filename);
}
dst = fopen(dst_path, "w");
--
1.5.6.5