Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Caco
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vytor Calixto
Caco
Commits
9b2b6ad8
Commit
9b2b6ad8
authored
9 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Created printErrors function
Signed-off-by:
Vytor Calixto
<
vytorcalixto@gmail.com
>
parent
4cb1f2ba
Branches
lento
Branches containing commit
No related tags found
1 merge request
!1
Lento
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Protocol.cpp
+12
-1
12 additions, 1 deletion
Protocol.cpp
client.cpp
+1
-1
1 addition, 1 deletion
client.cpp
dirFunctions.cpp
+1
-1
1 addition, 1 deletion
dirFunctions.cpp
with
14 additions
and
3 deletions
Protocol.cpp
+
12
−
1
View file @
9b2b6ad8
...
@@ -14,6 +14,16 @@ double timestamp(void) {
...
@@ -14,6 +14,16 @@ double timestamp(void) {
return
((
double
)(
tp
.
tv_sec
+
tp
.
tv_usec
/
1000000.0
));
return
((
double
)(
tp
.
tv_sec
+
tp
.
tv_usec
/
1000000.0
));
}
}
void
printErrors
(
char
error
){
if
(
error
==
DIR_ERR
){
cout
<<
"Arquivo ou diretório inexistente."
<<
endl
;
}
else
if
(
error
==
PERM_ERR
){
cout
<<
"Você não tem permissão."
<<
endl
;
}
else
if
(
error
==
SPACE_ERR
){
cout
<<
"Espaço insuficiente no disco."
<<
endl
;
}
}
vector
<
Message
>
Protocol
::
getMessages
(){
vector
<
Message
>
Protocol
::
getMessages
(){
return
messages
;
return
messages
;
}
}
...
@@ -221,7 +231,8 @@ int Protocol::receive(int sockt, int type, int window, bool dataEndable){
...
@@ -221,7 +231,8 @@ int Protocol::receive(int sockt, int type, int window, bool dataEndable){
nextSequence
=
(
messages
.
back
().
sequence
.
to_ulong
()
+
1
)
%
(
MAXSIZE
+
1
);
nextSequence
=
(
messages
.
back
().
sequence
.
to_ulong
()
+
1
)
%
(
MAXSIZE
+
1
);
}
}
}
else
if
(
status
==
ERROR
)
{
}
else
if
(
status
==
ERROR
)
{
cout
<<
"ERROR: "
<<
messages
.
back
().
getDataAsString
()
<<
endl
;
cout
<<
"ERROR: "
;
printErrors
(
messages
.
back
().
data
[
0
]);
return
-
1
;
return
-
1
;
}
}
}
while
(
status
!=
end
);
}
while
(
status
!=
end
);
...
...
This diff is collapsed.
Click to expand it.
client.cpp
+
1
−
1
View file @
9b2b6ad8
...
@@ -45,7 +45,7 @@ int main(){
...
@@ -45,7 +45,7 @@ int main(){
args
=
line
.
substr
(
pos
+
1
,
line
.
size
());
args
=
line
.
substr
(
pos
+
1
,
line
.
size
());
if
(
fexists
(
args
))
{
if
(
fexists
(
args
))
{
string
size
=
to_string
(
filesize
(
args
));
string
size
=
to_string
(
filesize
(
args
));
cout
<<
"ARQUIVO: "
<<
args
<<
"|
\t
TAMANHO:"
<<
size
<<
endl
;
//
cout << "ARQUIVO: " << args << "|\tTAMANHO:" << size << endl;
sendProtocol
.
setData
(
vector
<
BYTE
>
(
args
.
begin
(),
args
.
end
()),
PUT
);
sendProtocol
.
setData
(
vector
<
BYTE
>
(
args
.
begin
(),
args
.
end
()),
PUT
);
sendProtocol
.
sendMessage
(
sockt
,
0
);
sendProtocol
.
sendMessage
(
sockt
,
0
);
int
error
=
receiveProtocol
.
receive
(
sockt
,
OK
,
WAIT_STOP
,
false
);
int
error
=
receiveProtocol
.
receive
(
sockt
,
OK
,
WAIT_STOP
,
false
);
...
...
This diff is collapsed.
Click to expand it.
dirFunctions.cpp
+
1
−
1
View file @
9b2b6ad8
...
@@ -59,7 +59,7 @@ bool hasEnoughSpace(int size){
...
@@ -59,7 +59,7 @@ bool hasEnoughSpace(int size){
void
writeFile
(
string
path
,
vector
<
BYTE
>
data
){
void
writeFile
(
string
path
,
vector
<
BYTE
>
data
){
cout
<<
"path: "
<<
path
<<
endl
;
//
cout << "path: "<< path<<endl;
string
strData
(
data
.
begin
(),
data
.
end
());
string
strData
(
data
.
begin
(),
data
.
end
());
ofstream
file
(
path
);
ofstream
file
(
path
);
if
(
file
.
is_open
()){
if
(
file
.
is_open
()){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment