private static int doCreateFile(byte pathName[]) {
        
        //Check if file name length is > 32.
        if (pathName.length > 32) {
            doOutput("Kernel: User error: File name too long!\n");
            return -1;
        }
        
        //A 1 block byte array that will hold the free map
        byte freeMap[] = new byte[filesys.getBlockSizeOfDisk()];
        
        //Read block 0 into freeMap
        filesys.getDisk().read(0, freeMap);
        
        //Check if the file specified by pathName already exists.
        String pathNameString = new String(pathName);
        for (int i = 1; i < 100; i++) {
            if (freeMap[i] == '1'
                && pathNameString.equals(filesys.getFileTable()[i].trim())) {

                doOutput("Kernel: User error: File name already exists at"
                        + "block " + i + "!\n");
                return -1;
            }
        }
        
        //The target block to create the file to.
        int targetBlock = 1;
        //Search freeMap for the next 0, which will be the target block.
        for (int i = 1; i < filesys.getDisk().DISK_SIZE; i++) {
            if (freeMap[i] == '0') {
                targetBlock = i;
                break;
            }
        }
        
        //Byte array that will hold the path name and file contents.
        byte pathAndContents[] = new byte[filesys.getBlockSizeOfDisk()];
        //Copy path name to pathAndContents
        arraycopy(pathName, 0, pathAndContents, 0, pathName.length);
        
        //Write path and contents to the target block.
        filesys.getDisk().write(targetBlock, pathAndContents);
        
        //Update the free map at targetBlock indicating that block is occupied.
        freeMap[targetBlock] = '1';
        
        //Write free map back to block 0 of the disk.
        filesys.getDisk().write(0, freeMap);
        
        //Set the file system's fileTable at targetBlock to the file name so
        //we can look it up and other methods can use it.
        filesys.getFileTable()[targetBlock] = new String(pathName);
        
        //Indicate that file was created successfully.
        doOutput("Kernel: Created file ");
        for (int i = 0; i < pathName.length; i++) {
            doOutput((char) pathName[i] + "");
        }
        doOutput(" at block " + targetBlock + ". \n");
        
        return 0;
    }