Changeset 258
- Timestamp:
- 10/20/06 08:56:29 (2 years ago)
- Files:
-
- 1 modified
-
trunk/src/PDFDocument.cxx (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/PDFDocument.cxx
r257 r258 20 20 #include <time.h> 21 21 #include <poppler.h> 22 #include <unistd.h> 22 23 #include "epdfview.h" 23 24 … … 197 198 /// 198 199 gboolean 199 PDFDocument::loadFile (const gchar *filename, const gchar *password, 200 PDFDocument::loadFile (const gchar *filename, const gchar *password, 200 201 GError **error) 201 202 { … … 211 212 // Try to open the PDF document. 212 213 GError *loadError = NULL; 214 // In case the user specified to read the PDF file from the stdin 215 // (i.e., -), then we save the contents of the stdin to a temporary 216 // file and use the URI to this temporary file to load. 217 if ( g_ascii_strcasecmp ("-", filename) == 0 ) 218 { 219 gchar *tmpFileName; 220 gint fd = g_file_open_tmp ("epdfviewXXXXXX", &tmpFileName, error); 221 if ( -1 == fd ) 222 { 223 return FALSE; 224 } 225 while ( !feof (stdin) ) 226 { 227 gchar inputLine[512]; 228 size_t readBytes = fread (inputLine, sizeof (char), 229 sizeof (inputLine) / sizeof (char), 230 stdin); 231 write (fd, inputLine, readBytes); 232 } 233 close (fd); 234 235 g_free (filename_uri); 236 filename_uri = g_filename_to_uri (tmpFileName, NULL, error); 237 g_free (tmpFileName); 238 if ( NULL == filename_uri ) 239 { 240 return FALSE; 241 } 242 } 213 243 PopplerDocument *newDocument = 214 244 poppler_document_new_from_file (filename_uri, password, &loadError); … … 320 350 { 321 351 struct tm *tmpTime = localtime ((const time_t *)&creationDate); 322 if ( NULL != tmpTime )323 {352 if ( NULL != tmpTime ) 353 { 324 354 gchar *date = g_strnfill (DATE_LENGTH + 1, 0); 325 355 strftime (date, DATE_LENGTH, "%Y-%m-%d %H:%M:%S", tmpTime); 326 356 setCreationDate (date); 327 }357 } 328 358 } 329 359 else … … 338 368 { 339 369 struct tm *tmpTime = localtime ((const time_t *)&modDate); 340 if ( NULL != tmpTime )341 {342 gchar *date = g_strnfill (DATE_LENGTH + 1, 0);370 if ( NULL != tmpTime ) 371 { 372 gchar *date = g_strnfill (DATE_LENGTH + 1, 0); 343 373 strftime (date, DATE_LENGTH, "%Y-%m-%d %H:%M:%S", tmpTime); 344 374 setModifiedDate (date); 345 }375 } 346 376 } 347 377 else
