Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RaspberryCloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kk1205
RaspberryCloud
Commits
c8e8d04f
Commit
c8e8d04f
authored
Nov 28, 2015
by
srsdanny
Browse files
Options
Downloads
Patches
Plain Diff
Minor corrections
parent
8f556b5f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
program/Source/networking/FileServerConnection.cpp
+12
-4
12 additions, 4 deletions
program/Source/networking/FileServerConnection.cpp
program/Source/networking/HomeNetworkCommunications.cpp
+6
-2
6 additions, 2 deletions
program/Source/networking/HomeNetworkCommunications.cpp
with
18 additions
and
6 deletions
program/Source/networking/FileServerConnection.cpp
+
12
−
4
View file @
c8e8d04f
...
...
@@ -20,7 +20,7 @@ void FileServerConnection::run()
int
msgType
;
int
fileNameSize
;
streamsize
fileSize
;
long
long
fileSize
;
socket
().
receiveBytes
(
&
msgType
,
sizeof
(
msgType
));
socket
().
receiveBytes
(
&
fileNameSize
,
sizeof
(
fileNameSize
));
...
...
@@ -50,9 +50,9 @@ void FileServerConnection::run()
}
// Send file
auto
s
ize
=
getFileSize
(
file
);
fileS
ize
=
getFileSize
(
file
);
socket
().
sendBytes
(
&
OK_ANS
,
sizeof
(
OK_ANS
));
socket
().
sendBytes
(
&
s
ize
,
sizeof
(
s
ize
));
socket
().
sendBytes
(
&
fileS
ize
,
sizeof
(
fileS
ize
));
while
(
file
)
{
file
.
read
(
buffer
,
sizeof
(
buffer
));
...
...
@@ -67,7 +67,7 @@ void FileServerConnection::run()
socket
().
receiveBytes
(
&
fileSize
,
sizeof
(
fileSize
));
// Create file
ofstream
file
(
"out/"
+
fileName
,
ios
::
out
|
ios
::
binary
);
ofstream
file
(
dataFolder
+
fileName
,
ios
::
out
|
ios
::
binary
);
// Start receiving file
while
(
fileSize
!=
0
)
...
...
@@ -78,7 +78,15 @@ void FileServerConnection::run()
}
socket
().
sendBytes
(
&
OK_ANS
,
sizeof
(
OK_ANS
));
socket
().
close
();
file
.
close
();
cout
<<
"received: "
<<
fileName
<<
endl
;
auto
result
=
app
.
cfs
.
addFile
(
fileName
,
fileName
);
if
(
!
result
)
cout
<<
"error uploading file: "
<<
fileName
<<
endl
;
else
cout
<<
"successfully uploaded file: "
<<
fileName
<<
endl
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
program/Source/networking/HomeNetworkCommunications.cpp
+
6
−
2
View file @
c8e8d04f
...
...
@@ -66,7 +66,7 @@ bool HomeNetworkCommunications::addFileRemote(string fileID)
}
socket
.
receiveBytes
(
&
msgType
,
sizeof
(
msgType
));
if
(
msgType
!
=
OK_ANS
)
if
(
msgType
=
=
OK_ANS
)
// Successfully sent
return
true
;
...
...
@@ -87,7 +87,6 @@ ReturnableFile HomeNetworkCommunications::getFileRemote(string fileID)
return
result
;
}
int
msgType
;
int
fileNameSize
=
fileID
.
size
();
long
long
fileSize
;
...
...
@@ -112,6 +111,11 @@ ReturnableFile HomeNetworkCommunications::getFileRemote(string fileID)
// Get file
char
buffer
[
100000
];
ofstream
file
(
dataFolder
+
fileID
,
ios
::
out
|
ios
::
binary
);
if
(
!
file
)
{
result
.
setErrorMessage
(
"Error creating file"
);
return
result
;
}
socket
.
receiveBytes
(
&
fileSize
,
sizeof
(
fileSize
));
while
(
fileSize
!=
0
)
...
...
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