Skip to content

Commit 78c3b1a

Browse files
committed
v2.1
1. fix puts bugs
1 parent ce8d7ed commit 78c3b1a

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

client/bin/client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ int cmd_interpret(const DataPackage* data)
7777
&& strcmp(prefix, "mkdir"))
7878
{
7979
system("clear");
80-
printf("-----$ %s\n", data->buf);
8180
printf("invaild command\n");
81+
printf("-----$ %s\n", data->buf);
8282
return -1;
8383
}
8484
}

client/bin/transmission.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,8 @@ void* get_files(void* p)
925925
sprintf(path_name, "%s/%s", "downloads", trans_info->user_name);
926926
mkdir(path_name, 0775);
927927

928-
char cur_path[CMD_LEN];
929-
getcwd(cur_path, sizeof(cur_path));
928+
char main_path[CMD_LEN];
929+
getcwd(main_path, sizeof(main_path));
930930

931931
if (recv_cycle(socketFd, (char*)&data.data_len, sizeof(int)))
932932
{
@@ -937,7 +937,7 @@ void* get_files(void* p)
937937
{
938938
chdir(path_name);
939939
get_file(socketFd);
940-
chdir(cur_path);
940+
chdir(main_path);
941941
close(socketFd);
942942
pthread_exit(NULL);
943943
}
@@ -973,7 +973,7 @@ void* get_files(void* p)
973973
pthread_exit(NULL);
974974
}
975975
printf("All files are downloaded\n");
976-
chdir(cur_path);
976+
chdir(main_path);
977977
close(socketFd);
978978
pthread_exit(NULL);
979979
}
@@ -1206,6 +1206,7 @@ void* put_files(void* p)
12061206
while (j != i)
12071207
{
12081208
file_dir[j] = file_path[j];
1209+
j++;
12091210
}
12101211
}
12111212
i++;
@@ -1223,6 +1224,8 @@ void* put_files(void* p)
12231224
pthread_exit(NULL);
12241225
}
12251226

1227+
char cur_path[FILE_NAME_LEN];
1228+
getcwd(cur_path, sizeof(cur_path));
12261229
struct stat buf;
12271230
if (stat(file_path, &buf))
12281231
{
@@ -1231,8 +1234,6 @@ void* put_files(void* p)
12311234
}
12321235
if (S_ISDIR(buf.st_mode))
12331236
{
1234-
char cur_path[FILE_NAME_LEN];
1235-
getcwd(cur_path, sizeof(cur_path));
12361237
DIR* dp = opendir(file_path);
12371238

12381239
if (dp == NULL)
@@ -1277,8 +1278,6 @@ void* put_files(void* p)
12771278
}
12781279
else
12791280
{
1280-
char cur_path[FILE_NAME_LEN];
1281-
getcwd(cur_path, sizeof(cur_path));
12821281
if (chdir(file_dir))
12831282
{
12841283
printf("cannot open directory\n");

client/client

0 Bytes
Binary file not shown.

server/conf/server.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#max config length 50
33

44
#ip address
5-
ip_address 127.0.0.1
5+
ip_address 192.168.5.12
66

77
#port
88
port 8888

0 commit comments

Comments
 (0)