//the cat version that doesnt use lseek(), only read() import static cTools.KernelWrapper.*; //imports a Java Wrapper for C kernel functions, needs the sourced source_me import java.util.NoSuchElementException; import java.util.Scanner; import java.util.Arrays; import java.nio.charset.StandardCharsets; //implement public class cat{ public static void main(String[] args) { //double start = System.nanoTime(); boolean[] errarr = {false}; int count =0; boolean [] params = parseArgs(args);//extract parameters and remove them from args //System.out.println(Arrays.toString(args));//for testing boolean argsnull=true; for(int i=0;i1){ printThisLine = false; } } else{ countEmpty=0; printThisLine= true; } if(printThisLine){ if(params[2]){ System.out.print("\u001B[33m"+"["+Integer.toString(count)+"]"+"\u001B[0m"); count++; } System.out.println(buf); } } catch(NoSuchElementException e){ break; } } return count; } static int printFile(String f, boolean[] params, boolean[] errarr, int count){ //System.out.println(Arrays.toString(params)); int fd = open(f,O_RDONLY); int bufsz = Integer.MAX_VALUE/8; //test values? if (fd!=-1){ byte[] bytes = new byte[bufsz];//add length int rd = read(fd,bytes,bufsz); close(fd); byte[] cleanbytes = new byte[rd]; for (int i=0;i2&&t.charAt(t.length()-1)=='\n'&&t.charAt(t.length()-2)=='\n')){;} else{t = t+s.charAt(i);} } } else{t=s;} if(params[2]){//enumerate lines u = u + "\u001B[33m"+"["+Integer.toString(count)+"]"+"\u001B[0m"; count++; for (int i=0;i