См. документацию.00001
00002
00003
00004
00005
00006
00007
00008 #include "GetAttr.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 void GetAttr::setError(int errn){
00027 if(getType()==Result){
00028 Node* subNode=this->getKind(GetAttr_subNodeName);
00029 Node* n= new Node("errorno",subNode,GetAttr_xmlnsDataError);
00030 n->setXMLBody(errn);
00031 }
00032 }
00033
00034 int GetAttr::getError(){
00035 if(getType()==Result){
00036 Node* subNode=this->getKind(GetAttr_subNodeName);
00037 Node* n=subNode->getKind(GetAttr_xmlnsDataError);
00038 if (n!=NULL){
00039 return n->getXMLBodyInt();
00040 }
00041 }
00042 return 0;
00043 }
00044
00045
00046 void GetAttr::setPath(string path){
00047 if(getType()==Get){
00048 Node* subNode=this->getKind(GetAttr_subNodeName);
00049 Node* pathtofile = new Node("path",subNode,GetAttr_xmlnsDataPath);
00050 pathtofile->setXMLBody(path);
00051 }
00052 }
00053
00054 string GetAttr::getPath(){
00055 Node* subNode=this->getKind(GetAttr_subNodeName);
00056 if (subNode!=NULL){
00057 return subNode->getKind(GetAttr_xmlnsDataPath)->getXMLBody();
00058 }else{
00059 return "";
00060 }
00061 }
00062
00063 void GetAttr::setFileInfo(struct stat st ){
00064 if(getType()==Result){
00065 Node* subNode=this->getKind(GetAttr_subNodeName);
00066 Node* modefile = new Node("mode",subNode,GetAttr_xmlnsDataMode);
00067 modefile->setXMLBody(st.st_mode);
00068
00069 Node* nlinkfile = new Node("nlink",subNode,GetAttr_xmlnsDataNlink);
00070 nlinkfile->setXMLBody(st.st_nlink);
00071
00072 Node* sizefile = new Node("size",subNode,GetAttr_xmlnsDataSize);
00073 sizefile->setXMLBody(st.st_size);
00074
00075 Node* timefile = new Node("time",subNode,GetAttr_xmlnsDataTime);
00076 timefile->setAttribute("atime",st.st_atim.tv_sec);
00077 timefile->setAttribute("ctime",st.st_ctim.tv_sec);
00078 timefile->setAttribute("mtime",st.st_mtim.tv_sec);
00079 }
00080 }
00081
00082 struct stat GetAttr::getFileInfo(){
00083 struct stat res;
00084 memset(&res,0,sizeof(res));
00085 Node* subNode=this->getKind(GetAttr_subNodeName);
00086 if (subNode!=NULL){
00087 res.st_nlink=subNode->getKind(GetAttr_xmlnsDataNlink)->getXMLBodyInt();
00088 res.st_mode=subNode->getKind(GetAttr_xmlnsDataMode)->getXMLBodyInt();
00089 res.st_size=subNode->getKind(GetAttr_xmlnsDataSize)->getXMLBodyInt();
00090 Node* timeNode=subNode->getKind(GetAttr_xmlnsDataTime);
00091 res.st_atim.tv_sec=timeNode->getAttributeInt("atime");
00092 res.st_ctim.tv_sec=timeNode->getAttributeInt("ctime");
00093 res.st_mtim.tv_sec=timeNode->getAttributeInt("mtime");
00094 }
00095 return res;
00096 }
00097
00098 GetAttr::GetAttr(Node* parent,string from, string to, IQType type, string id):TagIQ(parent,from, to, type, id,GetAttr_xmlnsData) {
00099
00100 }
00101
00102 GetAttr::GetAttr(const Node &basedNode):TagIQ(basedNode){
00103 #ifdef debug_output
00104 cout<<"=======getattr constructor copy======"<<endl;
00105 #endif
00106 }
00107
00108 GetAttr::~GetAttr() {
00109
00110 }