diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/webbox.cpp | 64 | 
1 files changed, 58 insertions, 6 deletions
| diff --git a/src/webbox.cpp b/src/webbox.cpp index d0cfebc..51b6436 100644 --- a/src/webbox.cpp +++ b/src/webbox.cpp @@ -343,12 +343,16 @@ class InfoCommand: public PostCommand {  								QFileInfo fileInfo(m_path + "/" + filename);  								qint64 size = fileInfo.size();  								QString date = fileInfo.lastModified().toString(); -								QString type = fileInfo.isDir() ? "directory" : "file"; -								FCGX_PutS(QString("%1, %2 bytes, %3 (%4)<br>") -										.arg(filename) -										.arg(size) -										.arg(date) -										.arg(type).toUtf8().data(), p.request.out); +								if (fileInfo.isDir()) { +									FCGX_PutS(QString("%1, %2 (folder)<br>") +											.arg(filename) +											.arg(date).toUtf8().data(), p.request.out); +								} else { +									FCGX_PutS(QString("%1, %2 bytes, %3 (file)<br>") +											.arg(filename) +											.arg(size) +											.arg(date).toUtf8().data(), p.request.out); +								}  							}  						}  					} @@ -547,6 +551,51 @@ class MoveCommand: public PostCommand {  		}  }; +class RenameCommand: public PostCommand { +	public: +		RenameCommand() { +			m_commandName = "rename"; +			m_isWriteCommand = true; +		} + +	protected: +		virtual void start(CommandParameters& p) { +			if (!readContent(p)) +				return; + +			QXmlStreamReader xml(m_content); +			 +			QString oldname; +			QString newname; + +			while (!xml.atEnd()) { +				while (xml.readNextStartElement()) { +					if (xml.name() == "request") { +						while (xml.readNextStartElement()) { +							if (xml.name() == "oldname") { +								oldname = xml.readElementText(); +							} else +							if (xml.name() == "newname") { +								newname = xml.readElementText(); +							} +						} +					} +				} +			} +			 +			QDir dir(m_path); +			QString response; +			if (!dir.rename(oldname, newname)) { +				response = QString("Error renaming %1 to %2<br/>").arg(oldname).arg(newname); +			} else { +				response = "OK"; +			} +			 +			FCGX_PutS("Content-Type: text/plain\r\n\r\n", p.request.out); +			FCGX_PutS(response.toUtf8().data(), p.request.out); +		} +}; +  class UploadCommand: public PostCommand {  	public:  		UploadCommand() { @@ -712,6 +761,9 @@ int main(int argc, char* argv[]) {  	MoveCommand moveCommand;  	commands.registerCommand(moveCommand); +	RenameCommand renameCommand; +	commands.registerCommand(renameCommand); +	  	UploadCommand uploadCommand;  	commands.registerCommand(uploadCommand); | 
