mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5826 from chuanweizhang2013/cmdconsole
console variable init
This commit is contained in:
commit
7cbab6a9f7
|
@ -252,6 +252,8 @@ Console::Console()
|
|||
, _running(false)
|
||||
, _endThread(false)
|
||||
, _sendDebugStrings(false)
|
||||
,_fileUploading(false)
|
||||
,_uploadFileSize(0)
|
||||
{
|
||||
// VS2012 doesn't support initializer list, so we create a new array and assign its elements to '_command'.
|
||||
Command commands[] = {
|
||||
|
@ -290,6 +292,7 @@ Console::Console()
|
|||
{
|
||||
_commands.insert ( std::pair<std::string,Command>(commands[i].name,commands[i]) );
|
||||
}
|
||||
_writablePath = FileUtils::getInstance()->getWritablePath();
|
||||
}
|
||||
|
||||
Console::~Console()
|
||||
|
@ -759,9 +762,9 @@ void Console::commandUpload(int fd, const std::string& args)
|
|||
auto argv = split(args,' ');
|
||||
if(argv.size() == 2)
|
||||
{
|
||||
_upload_file_name = argv[0];
|
||||
_upload_file_size = std::atoi(argv[1].c_str());
|
||||
_file_uploading = true;
|
||||
_uploadFileName = argv[0];
|
||||
_uploadFileSize = std::atoi(argv[1].c_str());
|
||||
_fileUploading = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -853,10 +856,7 @@ ssize_t Console::readfile(int fd, std::string& file_name, int file_size)
|
|||
ssize_t n, rc;
|
||||
char c;
|
||||
|
||||
auto sharedFileUtils = FileUtils::getInstance();
|
||||
|
||||
std::string writablePath = sharedFileUtils->getWritablePath();
|
||||
std::string fileName = writablePath+file_name;
|
||||
std::string fileName = _writablePath+file_name;
|
||||
|
||||
FILE* fp = fopen(fileName.c_str(), "wb");
|
||||
if(!fp)
|
||||
|
@ -970,7 +970,7 @@ void Console::loop()
|
|||
for(const auto &fd: _fds) {
|
||||
if(FD_ISSET(fd,©_set))
|
||||
{
|
||||
if(!_file_uploading)
|
||||
if(!_fileUploading)
|
||||
{
|
||||
if( ! parseCommand(fd) )
|
||||
{
|
||||
|
@ -979,8 +979,8 @@ void Console::loop()
|
|||
}
|
||||
else
|
||||
{
|
||||
readfile(fd, _upload_file_name, _upload_file_size);
|
||||
_file_uploading = false;
|
||||
readfile(fd, _uploadFileName, _uploadFileSize);
|
||||
_fileUploading = false;
|
||||
|
||||
}
|
||||
if(--nready <= 0)
|
||||
|
|
|
@ -128,9 +128,10 @@ protected:
|
|||
bool _running;
|
||||
bool _endThread;
|
||||
|
||||
bool _file_uploading;
|
||||
ssize_t _upload_file_size;
|
||||
std::string _upload_file_name;
|
||||
bool _fileUploading;
|
||||
ssize_t _uploadFileSize;
|
||||
std::string _uploadFileName;
|
||||
std::string _writablePath;
|
||||
|
||||
std::map<std::string, Command> _commands;
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ bool CreateDir(const char *sPathName)
|
|||
bool FileServer::recv_file(int fd)
|
||||
{
|
||||
char buffer[1024]={0};
|
||||
char namelen[4]={0};
|
||||
char namelen[5]={0};
|
||||
if (recv(fd, namelen, 4,0)<=0) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue