mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-03-04 10:38:12 +00:00
Fix file handle leak
This commit is contained in:
parent
2a1e110a65
commit
6ff9db89cc
@ -651,12 +651,20 @@ public class FileSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized IMountedFile openFile( IMountedFile file ) throws FileSystemException
|
private synchronized IMountedFile openFile( IMountedFile file, Closeable handle ) throws FileSystemException
|
||||||
{
|
{
|
||||||
synchronized( m_openFiles )
|
synchronized( m_openFiles )
|
||||||
{
|
{
|
||||||
if( m_openFiles.size() >= ComputerCraft.maximumFilesOpen )
|
if( m_openFiles.size() >= ComputerCraft.maximumFilesOpen )
|
||||||
{
|
{
|
||||||
|
if( handle != null )
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
handle.close();
|
||||||
|
} catch ( IOException ignored ) {
|
||||||
|
// shrug
|
||||||
|
}
|
||||||
|
}
|
||||||
throw new FileSystemException("Too many files already open");
|
throw new FileSystemException("Too many files already open");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,7 +729,7 @@ public class FileSystem
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (IMountedFileNormal) openFile( file );
|
return (IMountedFileNormal) openFile( file, reader );
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -773,7 +781,7 @@ public class FileSystem
|
|||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (IMountedFileNormal) openFile( file );
|
return (IMountedFileNormal) openFile( file, writer );
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -811,7 +819,7 @@ public class FileSystem
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (IMountedFileBinary) openFile( file );
|
return (IMountedFileBinary) openFile( file, stream );
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -849,7 +857,7 @@ public class FileSystem
|
|||||||
stream.flush();
|
stream.flush();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (IMountedFileBinary) openFile( file );
|
return (IMountedFileBinary) openFile( file, stream );
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user