/[classpath]/classpath/gnu/java/nio/channels/FileChannelImpl.java
ViewVC logotype

Diff of /classpath/gnu/java/nio/channels/FileChannelImpl.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by mark, Tue Jul 26 09:40:21 2005 UTC revision 1.18 by mark, Tue Jul 26 12:01:10 2005 UTC
# Line 443  public final class FileChannelImpl exten Line 443  public final class FileChannelImpl exten
443      return total;      return total;
444    }    }
445    
446    public FileLock tryLock (long position, long size, boolean shared)    // Shared sanity checks between lock and tryLock methods.
447      private void lockCheck(long position, long size, boolean shared)
448      throws IOException      throws IOException
449    {    {
450      if (position < 0      if (position < 0
# Line 452  public final class FileChannelImpl exten Line 453  public final class FileChannelImpl exten
453                                            + ", size: " + size);                                            + ", size: " + size);
454    
455      if (!isOpen ())      if (!isOpen ())
456        throw new ClosedChannelException ();        throw new ClosedChannelException();
457    
458      if (shared && (mode & READ) == 0)      if (shared && ((mode & READ) == 0))
459        throw new NonReadableChannelException ();        throw new NonReadableChannelException();
           
     if (!shared && (mode & WRITE) == 0)  
       throw new NonWritableChannelException ();  
460                    
461        if (!shared && ((mode & WRITE) == 0))
462          throw new NonWritableChannelException();
463      }
464    
465      public FileLock tryLock (long position, long size, boolean shared)
466        throws IOException
467      {
468        lockCheck(position, size, shared);
469    
470      boolean completed = false;      boolean completed = false;
       
471      try      try
472        {        {
473          begin();          begin();
# Line 488  public final class FileChannelImpl exten Line 494  public final class FileChannelImpl exten
494    public FileLock lock (long position, long size, boolean shared)    public FileLock lock (long position, long size, boolean shared)
495      throws IOException      throws IOException
496    {    {
497      if (position < 0      lockCheck(position, size, shared);
         || size < 0)  
       throw new IllegalArgumentException ("position: " + position  
                                           + ", size: " + size);  
   
     if (!isOpen ())  
       throw new ClosedChannelException ();  
498    
499      boolean completed = false;      boolean completed = false;
   
500      try      try
501        {        {
502          boolean lockable = lock(position, size, shared, true);          boolean lockable = lock(position, size, shared, true);

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26