PageRenderTime 25ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/buffer/BufferAutosaveRequest.java

#
Java | 97 lines | 41 code | 10 blank | 46 comment | 3 complexity | 9a14d16b04061ffc29f68ac7123991de MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * BufferAutosaveRequest.java - I/O request
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2000, 2005 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. package org.gjt.sp.jedit.buffer;
  23. //{{{ Imports
  24. import java.io.*;
  25. import org.gjt.sp.jedit.io.*;
  26. import org.gjt.sp.jedit.*;
  27. import org.gjt.sp.util.*;
  28. //}}}
  29. /**
  30. * A buffer autosave request.
  31. * @author Slava Pestov
  32. * @version $Id: BufferAutosaveRequest.java 5486 2006-06-23 22:31:58Z kpouer $
  33. */
  34. public class BufferAutosaveRequest extends BufferIORequest
  35. {
  36. //{{{ BufferAutosaveRequest constructor
  37. /**
  38. * Creates a new buffer I/O request.
  39. * @param view The view
  40. * @param buffer The buffer
  41. * @param session The VFS session
  42. * @param vfs The VFS
  43. * @param path The path
  44. */
  45. public BufferAutosaveRequest(View view, Buffer buffer,
  46. Object session, VFS vfs, String path)
  47. {
  48. super(view,buffer,session,vfs,path);
  49. } //}}}
  50. //{{{ run() method
  51. public void run()
  52. {
  53. OutputStream out = null;
  54. try
  55. {
  56. String[] args = { vfs.getFileName(path) };
  57. setStatus(jEdit.getProperty("vfs.status.autosave",args));
  58. // the entire save operation can be aborted...
  59. setAbortable(true);
  60. try
  61. {
  62. //buffer.readLock();
  63. if(!buffer.isDirty())
  64. {
  65. // buffer has been saved while we
  66. // were waiting.
  67. return;
  68. }
  69. out = vfs._createOutputStream(session,path,view);
  70. if(out == null)
  71. return;
  72. write(buffer,out);
  73. }
  74. catch(Exception e)
  75. {
  76. }
  77. //finally
  78. //{
  79. //buffer.readUnlock();
  80. //}
  81. }
  82. catch(WorkThread.Abort a)
  83. {
  84. IOUtilities.closeQuietly(out);
  85. }
  86. } //}}}
  87. }