Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Caco Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
bfsc19
Caco Project
Commits
835b38d6
Commit
835b38d6
authored
2 years ago
by
bfsc19
Browse files
Options
Downloads
Patches
Plain Diff
feat: adicionada opção de mudar nome do arquivo ao receber
parent
fc1da369
Branches
Branches containing commit
No related tags found
1 merge request
!12
Resolve "feature corrigindo bugs arquivos e arrumando interface"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
headers/client.h
+2
-0
2 additions, 0 deletions
headers/client.h
headers/server.h
+19
-7
19 additions, 7 deletions
headers/server.h
with
21 additions
and
7 deletions
headers/client.h
+
2
−
0
View file @
835b38d6
...
...
@@ -111,6 +111,7 @@ int client::send_frame_socket(frame *f) {
return
1
;
}
// Inicia a transmissao com o servidor
int
client
::
start_transmission
()
{
cout
<<
"
\t
Iniciando transmissao
\n
"
;
...
...
@@ -230,6 +231,7 @@ vector<char> client::read_file(string fileName) {
return
fileData
;
}
/**
* @brief Send a file through the socket
*
...
...
This diff is collapsed.
Click to expand it.
headers/server.h
+
19
−
7
View file @
835b38d6
...
...
@@ -23,6 +23,7 @@
// include local
#include
"conexao.h"
#include
"frame.h"
#include
"cores.h"
#define FILE_DESTINATION "./received"
...
...
@@ -195,7 +196,7 @@ bool server::create_received_dir() {
}
// create the directory
if
(
mkdir
(
FILE_DESTINATION
,
07
00
)
==
-
1
)
{
if
(
mkdir
(
FILE_DESTINATION
,
07
77
)
==
-
1
)
{
cout
<<
"Erro ao criar o diretorio
\n
"
;
return
false
;
}
...
...
@@ -263,16 +264,22 @@ int server::receive_file_data(string fileName) {
fileDestination
.
push_back
(
'/'
);
fileDestination
.
append
(
fileName
);
cout
<<
BOLDGREEN
<<
"Criando arquivo "
<<
BOLDYELLOW
<<
fileDestination
<<
BOLDGREEN
<<
". Digite novo nome ou enter para continuar: "
<<
RESET
;
string
newDestination
=
""
;
getline
(
cin
,
newDestination
);
if
(
!
newDestination
.
empty
()
&&
newDestination
!=
"
\n
"
)
{
fileDestination
=
newDestination
;
}
cout
<<
YELLOW
<<
"Criando arquivo: "
<<
fileDestination
<<
"
\n
"
<<
RESET
;
// Abre o arquivo para escrita
ofstream
file
;
file
.
open
(
fileDestination
,
ios
::
binary
);
if
(
!
file
.
is_open
())
{
cout
<<
"
Falha ao criar o arquivo. Abortado
\n
"
;
cout
<<
RED
<<
"
\t
Falha ao criar o arquivo. Abortado
\n
"
<<
RESET
;
return
0
;
}
cout
<<
"Arquivo criado com sucesso
\n
"
;
int
lastSeq
=
1
;
frame
*
f
;
...
...
@@ -282,7 +289,12 @@ int server::receive_file_data(string fileName) {
// Fica tentando receber um frame
f
=
receive_frame_socket
();
if
(
f
==
NULL
)
{
return
0
;
}
if
(
f
==
NULL
)
{
cout
<<
"Erro ao receber dados do arquivo"
;
file
.
close
();
remove
(
fileDestination
.
c_str
());
return
0
;
}
cout
<<
"Frame recebido
\n
"
;
f
->
imprime
(
HEX
);
...
...
@@ -329,11 +341,11 @@ void server::receive_midia(frame *f) {
if
(
fileName
.
size
()
==
0
)
{
return
;
}
if
(
!
receive_file_data
(
fileName
)
)
{
cout
<<
"
Falha ao receber o arquivo
\n
"
;
cout
<<
RED
<<
"
\t
Falha ao receber o arquivo
\n
"
<<
RESET
;
return
;
}
cout
<<
"
Arquivo recebido com sucesso
\n
"
;
cout
<<
GREEN
<<
"
\t
Arquivo recebido com sucesso
\n
"
<<
RESET
;
}
// Recebe um frame do cliente
...
...
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