comparison data/fileio/MatrixFile.cpp @ 686:b4a8d8221eaf debug-output

Remove most toStdString calls (no longer needed, with debug header)
author Chris Cannam
date Thu, 12 May 2011 17:31:24 +0100
parents dfc4dd561bb6
children 06f13a3b9e9e
comparison
equal deleted inserted replaced
685:99222d4bfc78 686:b4a8d8221eaf
66 m_readyToReadColumn(-1) 66 m_readyToReadColumn(-1)
67 { 67 {
68 Profiler profiler("MatrixFile::MatrixFile", true); 68 Profiler profiler("MatrixFile::MatrixFile", true);
69 69
70 #ifdef DEBUG_MATRIX_FILE 70 #ifdef DEBUG_MATRIX_FILE
71 std::cerr << "MatrixFile::MatrixFile(" << fileBase.toStdString() << ", " << int(mode) << ", " << cellSize << ", " << width << ", " << height << ")" << std::endl; 71 std::cerr << "MatrixFile::MatrixFile(" << fileBase << ", " << int(mode) << ", " << cellSize << ", " << width << ", " << height << ")" << std::endl;
72 #endif 72 #endif
73 73
74 m_createMutex.lock(); 74 m_createMutex.lock();
75 75
76 QDir tempDir(TempDirectory::getInstance()->getPath()); 76 QDir tempDir(TempDirectory::getInstance()->getPath());
101 #ifdef _WIN32 101 #ifdef _WIN32
102 m_flags |= O_BINARY; 102 m_flags |= O_BINARY;
103 #endif 103 #endif
104 104
105 #ifdef DEBUG_MATRIX_FILE 105 #ifdef DEBUG_MATRIX_FILE
106 std::cerr << "MatrixFile(" << this << ")::MatrixFile: opening " << fileName.toStdString() << "..." << std::endl; 106 std::cerr << "MatrixFile(" << this << ")::MatrixFile: opening " << fileName << "..." << std::endl;
107 #endif 107 #endif
108 108
109 if ((m_fd = ::open(fileName.toLocal8Bit(), m_flags, m_fmode)) < 0) { 109 if ((m_fd = ::open(fileName.toLocal8Bit(), m_flags, m_fmode)) < 0) {
110 ::perror("Open failed"); 110 ::perror("Open failed");
111 std::cerr << "ERROR: MatrixFile::MatrixFile: " 111 std::cerr << "ERROR: MatrixFile::MatrixFile: "
112 << "Failed to open cache file \"" 112 << "Failed to open cache file \""
113 << fileName.toStdString() << "\""; 113 << fileName << "\"";
114 if (m_mode == WriteOnly) std::cerr << " for writing"; 114 if (m_mode == WriteOnly) std::cerr << " for writing";
115 std::cerr << std::endl; 115 std::cerr << std::endl;
116 throw FailedToOpenFile(fileName); 116 throw FailedToOpenFile(fileName);
117 } 117 }
118 118
128 size_t header[2]; 128 size_t header[2];
129 if (::read(m_fd, header, 2 * sizeof(size_t)) < 0) { 129 if (::read(m_fd, header, 2 * sizeof(size_t)) < 0) {
130 ::perror("MatrixFile::MatrixFile: read failed"); 130 ::perror("MatrixFile::MatrixFile: read failed");
131 std::cerr << "ERROR: MatrixFile::MatrixFile: " 131 std::cerr << "ERROR: MatrixFile::MatrixFile: "
132 << "Failed to read header (fd " << m_fd << ", file \"" 132 << "Failed to read header (fd " << m_fd << ", file \""
133 << fileName.toStdString() << "\")" << std::endl; 133 << fileName << "\")" << std::endl;
134 throw FileReadFailed(fileName); 134 throw FileReadFailed(fileName);
135 } 135 }
136 if (header[0] != m_width || header[1] != m_height) { 136 if (header[0] != m_width || header[1] != m_height) {
137 std::cerr << "ERROR: MatrixFile::MatrixFile: " 137 std::cerr << "ERROR: MatrixFile::MatrixFile: "
138 << "Dimensions in file header (" << header[0] << "x" 138 << "Dimensions in file header (" << header[0] << "x"
144 144
145 m_fileName = fileName; 145 m_fileName = fileName;
146 ++m_refcount[fileName]; 146 ++m_refcount[fileName];
147 147
148 #ifdef DEBUG_MATRIX_FILE 148 #ifdef DEBUG_MATRIX_FILE
149 std::cerr << "MatrixFile[" << m_fd << "]::MatrixFile: File " << fileName.toStdString() << ", ref " << m_refcount[fileName] << std::endl; 149 std::cerr << "MatrixFile[" << m_fd << "]::MatrixFile: File " << fileName << ", ref " << m_refcount[fileName] << std::endl;
150 150
151 std::cerr << "MatrixFile[" << m_fd << "]::MatrixFile: Done, size is " << "(" << m_width << ", " << m_height << ")" << std::endl; 151 std::cerr << "MatrixFile[" << m_fd << "]::MatrixFile: Done, size is " << "(" << m_width << ", " << m_height << ")" << std::endl;
152 #endif 152 #endif
153 153
154 ++totalCount; 154 ++totalCount;
171 if (m_fileName != "") { 171 if (m_fileName != "") {
172 172
173 if (--m_refcount[m_fileName] == 0) { 173 if (--m_refcount[m_fileName] == 0) {
174 174
175 if (::unlink(m_fileName.toLocal8Bit())) { 175 if (::unlink(m_fileName.toLocal8Bit())) {
176 std::cerr << "WARNING: MatrixFile::~MatrixFile: reference count reached 0, but failed to unlink file \"" << m_fileName.toStdString() << "\"" << std::endl; 176 std::cerr << "WARNING: MatrixFile::~MatrixFile: reference count reached 0, but failed to unlink file \"" << m_fileName << "\"" << std::endl;
177 } else { 177 } else {
178 std::cerr << "deleted " << m_fileName.toStdString() << std::endl; 178 std::cerr << "deleted " << m_fileName << std::endl;
179 } 179 }
180 } 180 }
181 } 181 }
182 182
183 if (m_mode == WriteOnly) { 183 if (m_mode == WriteOnly) {