Switch to unified view

a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp
...
...
949
// We then write the data out of the resulting document into the output file.
949
// We then write the data out of the resulting document into the output file.
950
// There are two temporary objects:
950
// There are two temporary objects:
951
// - The internfile temporary directory gets destroyed by its destructor
951
// - The internfile temporary directory gets destroyed by its destructor
952
// - The output temporary file which is held in a reference-counted
952
// - The output temporary file which is held in a reference-counted
953
//   object and will be deleted when done with.
953
//   object and will be deleted when done with.
954
// This DOES NOT work with a non-internal file (because at least one conversion 
955
// is always performed).
954
bool FileInterner::idocToFile(TempFile& otemp, const string& tofile,
956
bool FileInterner::idocToFile(TempFile& otemp, const string& tofile,
955
                  RclConfig *cnf, const Rcl::Doc& idoc)
957
                  RclConfig *cnf, const Rcl::Doc& idoc)
956
{
958
{
957
    LOGDEB(("FileInterner::idocToFile\n"));
959
    LOGDEB(("FileInterner::idocToFile\n"));
958
    idoc.dump();
960
    // idoc.dump();
961
962
    if (idoc.ipath.empty()) {
963
  LOGDEB(("FileInterner::idocToFile: not a sub-document !\n"));
964
  // We could do a copy here but it's much more complicated than
965
  // it seems because the source is not necessarily a simple
966
  // depending on the backend. Until we fix the Internfile
967
  // constructor to not do the first conversion, it's much saner
968
  // to just return an error
969
  return false;
970
    }
959
971
960
    // We set FIF_forPreview for consistency with the previous version
972
    // We set FIF_forPreview for consistency with the previous version
961
    // which determined this by looking at mtype!=null. Probably
973
    // which determined this by looking at mtype!=null. Probably
962
    // doesn't change anything in this case.
974
    // doesn't change anything in this case.
963
    FileInterner interner(idoc, cnf, FIF_forPreview);
975
    FileInterner interner(idoc, cnf, FIF_forPreview);
...
...
1002
    }
1014
    }
1003
    filename = temp->filename();
1015
    filename = temp->filename();
1004
    } else {
1016
    } else {
1005
    filename = tofile;
1017
    filename = tofile;
1006
    }
1018
    }
1019
1007
    int fd = open(filename.c_str(), O_WRONLY|O_CREAT, 0600);
1020
    int fd = open(filename.c_str(), O_WRONLY|O_CREAT, 0600);
1008
    if (fd < 0) {
1021
    if (fd < 0) {
1009
    LOGERR(("FileInterner::interntofile: open(%s) failed errno %d\n",
1022
    LOGERR(("FileInterner::interntofile: open(%s) failed errno %d\n",
1010
        filename.c_str(), errno));
1023
        filename.c_str(), errno));
1011
    return false;
1024
    return false;
...
...
1016
    LOGERR(("FileInterner::interntofile: write to %s failed errno %d\n",
1029
    LOGERR(("FileInterner::interntofile: write to %s failed errno %d\n",
1017
        filename.c_str(), errno));
1030
        filename.c_str(), errno));
1018
    return false;
1031
    return false;
1019
    }
1032
    }
1020
    close(fd);
1033
    close(fd);
1034
1021
    if (tofile.empty())
1035
    if (tofile.empty())
1022
    otemp = temp;
1036
    otemp = temp;
1023
    return true;
1037
    return true;
1024
}
1038
}
1025
1039