cmConfigureFileCommand
| 20 | |
| 21 | // cmConfigureFileCommand |
| 22 | bool cmConfigureFileCommand(std::vector<std::string> const& args, |
| 23 | cmExecutionStatus& status) |
| 24 | { |
| 25 | if (args.size() < 2) { |
| 26 | status.SetError("called with incorrect number of arguments, expected 2"); |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | std::string const& inFile = args[0]; |
| 31 | std::string const inputFile = cmSystemTools::CollapseFullPath( |
| 32 | inFile, status.GetMakefile().GetCurrentSourceDirectory()); |
| 33 | |
| 34 | // If the input location is a directory, error out. |
| 35 | if (cmSystemTools::FileIsDirectory(inputFile)) { |
| 36 | status.SetError(cmStrCat("input location\n ", inputFile, |
| 37 | "\n" |
| 38 | "is a directory but a file was expected.")); |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | std::string const& outFile = args[1]; |
| 43 | std::string outputFile = cmSystemTools::CollapseFullPath( |
| 44 | outFile, status.GetMakefile().GetCurrentBinaryDirectory()); |
| 45 | |
| 46 | // If the output location is already a directory put the file in it. |
| 47 | if (cmSystemTools::FileIsDirectory(outputFile)) { |
| 48 | outputFile += "/"; |
| 49 | outputFile += cmSystemTools::GetFilenameName(inFile); |
| 50 | } |
| 51 | |
| 52 | if (!status.GetMakefile().CanIWriteThisFile(outputFile)) { |
| 53 | std::string e = "attempted to configure a file: " + outputFile + |
| 54 | " into a source directory."; |
| 55 | status.SetError(e); |
| 56 | cmSystemTools::SetFatalErrorOccurred(); |
| 57 | return false; |
| 58 | } |
| 59 | std::string errorMessage; |
| 60 | cmNewLineStyle newLineStyle; |
| 61 | if (!newLineStyle.ReadFromArguments(args, errorMessage)) { |
| 62 | status.SetError(errorMessage); |
| 63 | return false; |
| 64 | } |
| 65 | bool copyOnly = false; |
| 66 | bool escapeQuotes = false; |
| 67 | bool useSourcePermissions = false; |
| 68 | bool noSourcePermissions = false; |
| 69 | bool filePermissions = false; |
| 70 | std::vector<std::string> filePermissionOptions; |
| 71 | |
| 72 | enum class Doing |
| 73 | { |
| 74 | DoingNone, |
| 75 | DoingFilePermissions, |
| 76 | DoneFilePermissions |
| 77 | }; |
| 78 | |
| 79 | Doing doing = Doing::DoingNone; |
nothing calls this directly
no test coverage detected
searching dependent graphs…