Author Topic: Save errors - can't save a temp view?  (Read 4603 times)

PChady

  • Community Member
  • Posts: 18
  • Hero Points: 1
Save errors - can't save a temp view?
« on: April 09, 2008, 10:31:34 pm »
Hi,

does _save_file() work for a temp view?


The save returns an error for me every time. I am working on a file opened with this:

            ret = _open_temp_view( ProjectFileList[pLength][1], file_temp_view_id, junk );
            p_view_id = file_temp_view_id;
       
           [... stuff ...]

            status = _save_file('+FD') ;

thanks,

Pete

hs2

  • Senior Community Member
  • Posts: 2743
  • Hero Points: 288
Re: Save errors - can't save a temp view?
« Reply #1 on: April 09, 2008, 10:44:52 pm »
I'd propose to use 'save_as()' in this case. HS2

hs2

  • Senior Community Member
  • Posts: 2743
  • Hero Points: 288
Re: Save errors - can't save a temp view?
« Reply #2 on: April 09, 2008, 11:34:04 pm »
Sorry, my bad. This is not a real solution. Didn't read the post carefully enough  :-[
But I'm not sure about 'ProjectFileList[pLength][1]'
Perhaps you should check the filename e.g. using
Quote
say("file '" ProjectFileList[pLength] "' opened");
.
What's the return code of _save_file() ?
You can lookup the number in 'rc.sh' or use this to get the error text:
Code: [Select]
say ("status = " status " - " get_message (status));
BTW:
Quote
p_view_id ... is deprecated. Use the p_window_id property ...

Good luck, HS2

PChady

  • Community Member
  • Posts: 18
  • Hero Points: 1
Re: Save errors - can't save a temp view?
« Reply #3 on: April 10, 2008, 09:48:40 pm »
Hi -
 I know the filename thing looks weird.. it's in a big loop that's going through the whole workspace.
But, the filenames get printed out, and they're ok.

return code is:

#define FAILED_TO_BACKUP_FILE_RC -2101
// Failed to copy/move %s1 to %s2.  Access denied.

So that's a good clue.  I'll add the printout, too.

Thanks for the tip!
I did try the save as, and that let me get the files saved (with user prompting), but the edits weren't present in the save...

thanks,
Pete

hs2

  • Senior Community Member
  • Posts: 2743
  • Hero Points: 288
Re: Save errors - can't save a temp view?
« Reply #4 on: April 10, 2008, 10:11:37 pm »
Maybe the usage of _open_temp_view is not correct.
I'd propose to specify '+b' as load option.
Note that the temp buffer is already active after calling _open_temp_view().
Code: [Select]
   int status=_open_temp_view(filename, temp_window_id, orig_window_id,"+b");
   // do some stuff (the temp view/buffer is active)

   _delete_temp_view(temp_window_id);
   activate_window(orig_window_id);  // or just p_window_id = orig_window_id;
HS2