OSDN Git Service

scene2d.ui Disableable interface.
[mikumikustudio/libgdx-mikumikustudio.git] / backends / gdx-backend-iosmonotouch / src / com / badlogic / gdx / backends / ios / IOSStreamInput.java
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 package com.badlogic.gdx.backends.ios;
17
18 import java.io.IOException;
19 import java.io.InputStream;
20
21 import cli.System.IO.Stream;
22
23 public class IOSStreamInput extends InputStream {
24
25         /** The stream for I/O operation. */
26         private Stream stream;
27         /** True if we can close the stream here. */
28         private boolean closeable;
29         
30         
31         public IOSStreamInput(Stream stream) {
32                 this(stream, true);
33         }
34         
35         public IOSStreamInput(Stream stream, boolean closeable) {
36                 this.stream = stream;
37                 this.closeable = closeable;
38         }
39         
40         @Override
41         public int available () throws IOException {
42                 // NOTE: not supported!
43                 return 0;
44         }
45
46         @Override
47         public synchronized void mark (int readLimit) {
48                 // not implemented
49         }
50
51         @Override
52         public boolean markSupported () {
53                 return false;
54         }
55
56         @Override
57         public synchronized void reset () throws IOException {
58                 // not implemented
59         }
60
61         @Override
62         public int read () throws IOException {
63                 return stream.ReadByte();
64         }
65
66         @Override
67         public int read (byte[] b) throws IOException {
68                 return read(b, 0, b.length);
69         }
70
71         @Override
72         public int read (byte[] b, int off, int len) throws IOException {
73                 return stream.Read(b, off, len);
74         }
75
76         @Override
77         public void close () throws IOException {
78                 if (closeable) {
79                         stream.Close();
80                         stream = null;
81                 }
82         }
83 }