// // Copyright 2007 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wWorkspaceFileView: // Generate the call to RenderLocal() in p4wMimeContentPane #include <stdlib.h> #include <string.h> #include <p4wp4.h> #include "p4wView.h" #include "p4wWorkspaceFileView.h" #include "p4wMimeContentPane.h" #include "p4wPasswdTestPane.h" #include "p4wFstatPane.h" p4wWorkspaceFileView::p4wWorkspaceFileView( p4wRequest & Request ) : p4wView(Request) { } p4wWorkspaceFileView::~p4wWorkspaceFileView() { } void p4wWorkspaceFileView::Render() { StrBuf path; path.Set( fRequest.GetPath() ); char *p = path.Text(); while (*p == '/') strcpy(p, p+1); path.SetLength(); // run p4 info to get the client's root p4wPasswdTestPane dummyCmd( *this, fRequest ); fRequest.p4( "info", 0, 0, &dummyCmd ); fRequest.p4Wait(); StrBuf fullpath; if (fRequest.GetCmd() == AC_WORKSPACEFILE) { fullpath.Set(dummyCmd.GetClientRoot()); #ifdef OS_NT while (p = strchr(p, '/')) *p = '\\'; fullpath << "\\" << path; #else fullpath << "/" << path; #endif } else { #ifdef OS_NT char slash = '\\'; #else char slash = '/'; #endif StrBuf root; root.Set(dummyCmd.GetClientRoot()); if (!strncmp(root.Text(), path.Text(), root.Length()) && !strstr(path.Text(), "..") && *(path.Text() + root.Length()) == slash) { fullpath.Set(path); } else // don't have local path under client root { // need to run fstat p4wFstatPane fstatPane(*this, fRequest); fRequest.p4Arg( "-C" ); fRequest.p4Arg( fRequest.GetPath().Text() ); fRequest.p4( "fstat", 0, 0, &fstatPane ); fRequest.p4Wait(); path.Set(fstatPane.fClientFile); if (!strncmp(root.Text(), path.Text(), root.Length()) && !strstr(path.Text(), "..") && *(path.Text() + root.Length()) == slash) { fullpath.Set(path); } else { fRequest << "<font color=\"#FF0000\">Invalid file path: "; fRequest << fRequest.GetPath().Text() << "</font>"; return; } } } if (strstr(fullpath.Text(), "..")) { fRequest << "<font color=\"#FF0000\">Invalid file path: "; fRequest << fRequest.GetPath().Text() << "</font>"; return; } p4wMimeContentPane localPane( *this, fRequest ); localPane.RenderLocal( fullpath.Text(), 1 ); if (localPane.fOpenFailed) { fRequest << "Unable to read file: "; fRequest << fRequest.GetPath().Text(); return; } } void p4wWorkspaceFileView::RenderMenu() { }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 12234 | Matt Attaway |
Rejigger P4Web project in preparation for official sunsetting The bin directory contains the last official builds of P4Web from the Perforce download site. P4Web is soon to be completely sunsetted; these builds are here for folks who don't want to build their own. To better handle the archived builds the source code has been moved into a separate src directory. |
||
//guest/perforce_software/p4web/Views/p4wWorkspaceFileView.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |