1 package com.tapina.robe.swi.clib.stdio;
2
3 import com.tapina.robe.runtime.Environment;
4 import com.tapina.robe.swi.clib.Stub;
5
6 import java.io.IOException;
7
8 /***
9 * This function sets the file pointer for the stream to the beginning of the file.
10 * It is equivalent to fseek (stream, 0, SEEK_SET );
11 */
12 public class Rewind extends Stub {
13 public void executeStub(Environment environment) {
14 final int[] R = environment.getCpu().R;
15 FilePointer filePointer = FilePointer.find(environment.getMemoryMap().getWord(R[0]));
16 try {
17 filePointer.setPosition(0);
18 } catch (IOException e) {
19 log.warning("Error in rewind(): " + e.getMessage());
20 }
21 }
22 }