~ubuntu-branches/ubuntu/jaunty/cmake/jaunty-security

« back to all changes in this revision

Viewing changes to Source/cmWriteFileCommand.cxx

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2006-06-18 16:34:11 UTC
  • mfrom: (1.4.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060618163411-pi234s3v6jwlcmof
Tags: 2.4.2-1
* New upstream release (Closes: #338324)
* Put cmake .vim files into /usr/share/vim/addons/plugin/
  where they can be used. (Closes: #366663)
* Install cmake-mode.el so it can be used. (Closes: #366664)
* Ensure cmake FindKDE locates KDE libraries on Debian
  based distributions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  Program:   CMake - Cross-Platform Makefile Generator
4
4
  Module:    $RCSfile: cmWriteFileCommand.cxx,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2005/07/06 19:51:11 $
7
 
  Version:   $Revision: 1.11 $
 
6
  Date:      $Date: 2006/05/14 19:22:44 $
 
7
  Version:   $Revision: 1.14.2.1 $
8
8
 
9
9
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
10
10
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
16
16
=========================================================================*/
17
17
#include "cmWriteFileCommand.h"
18
18
 
 
19
#include <sys/types.h>
 
20
#include <sys/stat.h>
 
21
 
19
22
// cmLibraryCommand
20
23
bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args)
21
24
{
42
45
      message += *i;
43
46
      }
44
47
    }
 
48
 
 
49
  if ( !this->Makefile->CanIWriteThisFile(fileName.c_str()) )
 
50
    {
 
51
    std::string e = "attempted to write a file: " + fileName
 
52
      + " into a source directory.";
 
53
    this->SetError(e.c_str());
 
54
    cmSystemTools::SetFatalErrorOccured();
 
55
    return false;
 
56
    }
 
57
 
45
58
  std::string dir = cmSystemTools::GetFilenamePath(fileName);
46
59
  cmSystemTools::MakeDirectory(dir.c_str());
47
60
 
70
83
    }
71
84
  // If GetPermissions fails, pretend like it is ok. File open will fail if
72
85
  // the file is not writable
73
 
  std::ofstream file(fileName.c_str(), overwrite?std::ios::out : std::ios::app);
 
86
  std::ofstream file(fileName.c_str(), 
 
87
                     overwrite?std::ios::out : std::ios::app);
74
88
  if ( !file )
75
89
    {
76
90
    std::string error = "Internal CMake error when trying to open file: ";
82
96
  file << message << std::endl;
83
97
  file.close();
84
98
  cmSystemTools::SetPermissions(fileName.c_str(), mode);
85
 
  m_Makefile->AddWrittenFile(fileName.c_str());
 
99
  this->Makefile->AddWrittenFile(fileName.c_str());
86
100
 
87
101
  return true;
88
102
}