-
-
Save oppahero/95ad277d9256c83c4efc0ae96b361fcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Server::on_client_fileSend(QString uname,QString filename,QByteArray dataOfFile){ | |
ClientThread* client = (ClientThread*)sender(); | |
QString currentTime = QTime::currentTime().toString("H:mm A/"); | |
QString command = "/fileAll:"+currentTime + uname + " : " + filename + "\n"; | |
QString filePath; | |
//Si no esta la carpeta creada, la crea. | |
if(!QDir("Documentos_Servidor").exists()){ | |
qDebug() << "No esta creada la carpeta"; | |
QDir().mkdir("Documentos_Servidor"); | |
} | |
filePath ="Documentos_Servidor"; | |
//Crea el archivo | |
QFile outFile(filePath+"/"+filename); | |
lastFileGroup = filePath + "/" + filename; | |
//Lo abre | |
if(!outFile.open(QIODevice::WriteOnly)){ | |
qDebug() << "Error al intentar abrir el archivo"; | |
return; | |
} | |
//escribe el contenido del ByteArray en el archivo y lo cierra | |
outFile.write(dataOfFile); | |
outFile.close(); | |
this->sendDataFileToAll(command,dataOfFile,client); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment