Changeset 3007 for trunk/gsdl/src/recpt/collectoraction.cpp
- Timestamp:
- 2002-02-27T11:50:16+13:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/collectoraction.cpp
r2908 r3007 45 45 #include "argdb.h" 46 46 #include "cgiutils.h" 47 #include <stdio.h> 48 #include <fcntl.h> 47 49 48 50 #if !defined (__WIN32__) … … 581 583 582 584 // now write cfg file back out 583 #ifdef __WIN32__ 584 ofstream cfg_out (cfgfilec, ios::binary); 585 #else 586 ofstream cfg_out (cfgfilec); 585 int fd=open(cfgfilec, O_WRONLY | O_CREAT | O_TRUNC 586 #if defined(__WIN32__) 587 | O_BINARY 587 588 #endif 588 if (cfg_out) { 589 ); 590 591 if (fd != -1) { 589 592 // lock the file 590 int fd = GSDL_GET_FILEDESC(cfg_out);591 593 int lock_val = 1; 592 594 GSDL_LOCK_FILE (fd); 593 595 if (lock_val != 0) { 594 596 logout << "Error: Couldn't lock file " << cfgfilec << "\n"; 595 c fg_out.close();597 close(fd); 596 598 message = "tmpfail"; 597 599 … … 601 603 vector<text_tarray>::const_iterator end_line = cfgarray.end(); 602 604 while (this_line != end_line) { 603 write_cfg_line ( cfg_out, *this_line);605 write_cfg_line (fd, *this_line); 604 606 this_line ++; 605 607 } 606 608 GSDL_UNLOCK_FILE (fd); 607 c fg_out.close();609 close(fd); 608 610 } 609 611 … … 633 635 // make sure collect.cfg isn't read-only 634 636 _chmod (cfgfilec, _S_IREAD | _S_IWRITE); 635 ofstream cfg_out (cfgfilec, ios::binary);636 #else637 ofstream cfg_out (cfgfilec);638 637 #endif 639 640 if (cfg_out) { 638 639 int fd=open(cfgfilec, O_WRONLY | O_CREAT | O_TRUNC 640 #if defined(__WIN32__) 641 | O_BINARY 642 #endif 643 ); 644 645 if (fd) { 641 646 // lock the file 642 int fd = GSDL_GET_FILEDESC(cfg_out);643 647 int lock_val = 1; 644 648 GSDL_LOCK_FILE (fd); 645 649 if (lock_val != 0) { 646 650 logout << "Error: Couldn't lock file " << cfgfilec << "\n"; 647 c fg_out.close();651 close(fd); 648 652 message = "tmpfail"; 649 653 … … 651 655 652 656 outconvertclass text_t2ascii; 653 cfg_out << text_t2ascii << args["cfgfile"]; 657 text_t2ascii << args["cfgfile"]; 658 size_t buffersize=args["cfgfile"].size(); 659 char *buffer=new char[buffersize]; 660 size_t num_chars; 661 convertclass::status_t status; 662 text_t2ascii.convert(buffer, buffersize, num_chars, status); 663 // ignore status - assume it is "finished" as buffer is big enough 664 write(fd, buffer, num_chars); 654 665 GSDL_UNLOCK_FILE (fd); 655 cfg_out.close(); 666 close(fd); 667 delete buffer; 656 668 657 669 // now that we've written the file we'll read it back again and … … 1490 1502 shortname.clear(); 1491 1503 int use_words = (num_words <= 6) ? num_words : 6; 1492 int substr_len = 6 / use_words;1504 unsigned int substr_len = 6 / use_words; 1493 1505 1494 1506 for (int i = 0; i < use_words; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.