nglString nuiFileTree::GetFileInfo(const nglPath& rPath) { nglString str; nglPathInfo info; rPath.GetInfo(info); // file modification date nglTimeInfo timeInfo; nglString timestr; nglTime lastMod = info.LastMod; lastMod.GetLocalTime(timeInfo); timestr.Format(_T("%d/%d/%d, %d:%d"), timeInfo.Year+1900, timeInfo.Month, timeInfo.Day, timeInfo.Hours, timeInfo.Minutes); str.Append(timestr); if (rPath.IsLeaf()) { // file size str.Append(_T(" - ")); FormatFileSize(info.Size, str); } return str; }
bool ProjectGenerator::CopyDirectory(const nglPath& targetPath, const nglPath& srcpath) { // create folder if (!targetPath.Create()) { nglString msg; msg.Format(_T("creating target folder '%ls'"), targetPath.GetChars()); return MsgError(msg); } std::list<nglPath> children; srcpath.GetChildren(&children); std::list<nglPath>::iterator it; for (it = children.begin(); it != children.end(); ++it) { const nglPath& srcpath = *it; if (!srcpath.IsLeaf()) continue; nglPath dstpath = targetPath; dstpath += srcpath.GetNodeName(); nglString contents; nglIStream* piFile = srcpath.OpenRead(); if (!piFile) { nglString msg; msg.Format(_T("opening for reading input file '%ls'"), srcpath.GetChars()); return MsgError(msg); } nglOStream* poFile = dstpath.OpenWrite(false); if (!poFile) { nglString msg; msg.Format(_T("opening for writing output file '%ls'"), dstpath.GetChars()); return MsgError(msg); } piFile->PipeTo(*poFile); delete poFile; delete piFile; NGL_OUT(_T("nui project generator : created file '%ls'\n"), dstpath.GetChars()); } return true; }