I've dropped the ball on this, but it's something that should be fixed before releasing lyx-136. Just a reminder: when graphics files are copied to the tmp directory in MacOS X, the copy fails resulting in empty (0kB) files. Consequently, typesetting fails on any file with graphics.

Angus wrote:

Specifically, I changed this on 14 Dec:

-    ifstream ifs(from.c_str());
+    ifstream ifs(from.c_str(), ios::binary);

Try out Lar's suggestion of a small stand-alone program. Makes it easy to
see which suggested change makes a difference for you.

Changing that back fixes the problem.

Lars' suggestion is below; however, I don't know enough to get his test program to work. Any pointers?

Bennett

On Jan 6, 2005, at 9:40 AM, Lars Gullik Bjønnes wrote:

|  bool lyx::copy(string const & from, string const & to)
|  {
|      ifstream ifs(from.c_str(), ios::binary);
|      if (!ifs)
|          return false;
|      ofstream ofs(to.c_str(),
|                   ios::binary | ios::out | ios::trunc);
|      if (!ofs)
|          return false;
|      ofs << ifs.rdbuf();
| +    flush(ofs);
|      if (ofs.good())
|          return true;
|      return false;
|  }

I have never seen this fail before. So before adding hacks to it I'd
like to know _why_ and _how_ it fails.

Should be easy to create a small test prog for this:

#include <fstream>
#include <iostream>
#include <string>

using std::string;
using std::ifstream;
using std::ofstream;

bool lyx::copy(string const & from, string const & to)
{
    ifstream ifs(from.c_str(), ios::binary);
    if (!ifs)
        return false;
    ofstream ofs(to.c_str(),
                 ios::binary | ios::out | ios::trunc);
    if (!ofs)
        return false;
    ofs << ifs.rdbuf();
    if (ofs.good())
        return true;
    return false;
}

int main(int argc, char * argv[])
{
        bool res = lyx::copy(argv[1], argv[2]);
        if (res)
           std::cout << "copy ok" << std::endl;
        else
           std::cout << "copy NOT ok" << std::endl;

        return !res;
}

and check the size after copy.
and then figure out if it always fails, or only in some circumstances.



Reply via email to