Task 177: .EMAKER File Format

Task 177: .EMAKER File Format

1. List of all the properties of this file format intrinsic to its file system

Based on research, the .EMAKER file format is used for source code files in the E programming language, specifically for "makers" (factory functions or objects that create other objects). It is a plain text format with no binary structure or magic number. The properties intrinsic to its file system are standard for text files, but specific to this format:

  • File extension: .emaker (case-insensitive, but typically lowercase)
  • MIME type: text/plain (no official MIME type defined; treated as plain text)
  • File signature/magic number: None (it is a text file, identifiable by content and extension)
  • Encoding: ASCII or UTF-8 (E language source code is human-readable text)
  • Structure: Unstructured text following E language syntax; typically begins with a "def" declaration for a maker function or object, and ends with a return statement or object definition
  • Size: Variable, dependent on the length of the source code
  • Permissions: Standard file system permissions (e.g., read/write/execute based on OS; no format-specific restrictions)
  • Creation/modification dates: Standard file system timestamps
  • Path handling: Often placed in Java classpath directories for import, using package paths like com.yourdomain.e.example.emaker
  • Security properties: The file itself has no inherent security; when imported in E, the code executes with no initial authority (Principle of Least Authority), receiving capabilities only via arguments
  • Content type: E language source code, executed on import to return an object or function

These are derived from the E language documentation.

No direct download links for .EMAKER files were found in web searches or E language documentation. The E language is an older, niche project focused on secure distributed computing, and sample files are primarily shown as code snippets in documentation rather than downloadable files. The E-on-Java implementation download (available at http://www.erights.org/download/0-8-36/e-0.8.36c.jar or similar archived versions) does not explicitly include .EMAKER samples, though it may contain related source code. GitHub searches for E language repositories also yielded no .EMAKER files.

3. Ghost blog embedded html javascript that allows a user to drag n drop a file of format .EMAKER and it will dump to screen all these properties

Here is an embeddable HTML snippet with JavaScript that can be used in a Ghost blog post (or any HTML-enabled blog). It creates a drag-and-drop area for a .EMAKER file. Upon drop, it reads the file as text (since .EMAKER is plain text), validates it's text-based, and dumps the properties listed in #1 along with the file content (as the "content" property). It also extracts basic E syntax elements like the defined maker name for a simple "dump".

Drag and drop a .EMAKER file here

4. Python class that can open any file of format .EMAKER and decode read and write and print to console all the properties from the above list

Since .EMAKER is plain text, "decode" here means reading as text. The class reads the file, prints the properties (including content), and can write a new file with modified content.

import os
import datetime

class EMakerFileHandler:
    def __init__(self, filepath):
        self.filepath = filepath
        self.content = None
        self.properties = {}

    def read_and_decode(self):
        with open(self.filepath, 'r', encoding='utf-8') as f:
            self.content = f.read()
        # Simple parse for maker name
        import re
        maker_match = re.search(r'def\s+(\w+)', self.content)
        maker_name = maker_match.group(1) if maker_match else 'Unknown'

        stat = os.stat(self.filepath)
        self.properties = {
            'File Extension': '.emaker',
            'MIME Type': 'text/plain',
            'File Signature': 'None (text file)',
            'Encoding': 'UTF-8' if any(ord(c) > 127 for c in self.content) else 'ASCII',
            'Structure': 'E language source code',
            'Size': f'{stat.st_size} bytes',
            'Last Modified': datetime.datetime.fromtimestamp(stat.st_mtime).strftime('%Y-%m-%d %H:%M:%S'),
            'Security Properties': 'Executes with no initial authority in E',
            'Content Type': 'E source code (maker)',
            'Defined Maker': maker_name,
            'Full Content': self.content
        }

    def print_properties(self):
        if not self.properties:
            self.read_and_decode()
        for key, value in self.properties.items():
            print(f'{key}: {value}')

    def write(self, new_content, new_filepath=None):
        filepath = new_filepath or self.filepath
        with open(filepath, 'w', encoding='utf-8') as f:
            f.write(new_content)
        print(f'Written to {filepath}')

# Example usage:
# handler = EMakerFileHandler('example.emaker')
# handler.print_properties()
# handler.write('new content', 'new.emaker')

5. Java class that can open any file of format .EMAKER and decode read and write and print to console all the properties from the above list

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class EMakerFileHandler {
    private String filepath;
    private String content;
    private final Pattern makerPattern = Pattern.compile("def\\s+(\\w+)");

    public EMakerFileHandler(String filepath) {
        this.filepath = filepath;
    }

    public void readAndDecode() throws IOException {
        byte[] bytes = Files.readAllBytes(new File(filepath).toPath());
        content = new String(bytes, StandardCharsets.UTF_8);
        Matcher matcher = makerPattern.matcher(content);
        String makerName = matcher.find() ? matcher.group(1) : "Unknown";

        File file = new File(filepath);
        BasicFileAttributes attrs = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
        FileTime lastModified = attrs.lastModifiedTime();

        System.out.println("File Extension: .emaker");
        System.out.println("MIME Type: text/plain");
        System.out.println("File Signature: None (text file)");
        System.out.println("Encoding: " + (content.chars().anyMatch(c -> c > 127) ? "UTF-8" : "ASCII"));
        System.out.println("Structure: E language source code");
        System.out.println("Size: " + file.length() + " bytes");
        System.out.println("Last Modified: " + lastModified);
        System.out.println("Security Properties: Executes with no initial authority in E");
        System.out.println("Content Type: E source code (maker)");
        System.out.println("Defined Maker: " + makerName);
        System.out.println("Full Content:\n" + content);
    }

    public void write(String newContent, String newFilepath) throws IOException {
        try (FileWriter writer = new FileWriter(newFilepath == null ? filepath : newFilepath)) {
            writer.write(newContent);
        }
        System.out.println("Written to " + (newFilepath == null ? filepath : newFilepath));
    }

    // Example usage:
    // public static void main(String[] args) throws IOException {
    //     EMakerFileHandler handler = new EMakerFileHandler("example.emaker");
    //     handler.readAndDecode();
    //     handler.write("new content", "new.emaker");
    // }
}

6. Javascript class that can open any file of format .EMAKER and decode read and write and print to console all the properties from the above list

Note: JavaScript in browser context uses FileReader for reading; for Node.js, use fs module. This is for Node.js.

const fs = require('fs');
const path = require('path');

class EMakerFileHandler {
  constructor(filepath) {
    this.filepath = filepath;
    this.content = null;
  }

  readAndDecode() {
    this.content = fs.readFileSync(this.filepath, 'utf8');
    const makerMatch = this.content.match(/def\s+(\w+)/);
    const makerName = makerMatch ? makerMatch[1] : 'Unknown';

    const stat = fs.statSync(this.filepath);
    const isUTF8 = [...this.content].some(c => c.charCodeAt(0) > 127);

    console.log('File Extension: .emaker');
    console.log('MIME Type: text/plain');
    console.log('File Signature: None (text file)');
    console.log('Encoding:', isUTF8 ? 'UTF-8' : 'ASCII');
    console.log('Structure: E language source code');
    console.log('Size:', stat.size, 'bytes');
    console.log('Last Modified:', new Date(stat.mtime).toString());
    console.log('Security Properties: Executes with no initial authority in E');
    console.log('Content Type: E source code (maker)');
    console.log('Defined Maker:', makerName);
    console.log('Full Content:\n', this.content);
  }

  write(newContent, newFilepath = null) {
    fs.writeFileSync(newFilepath || this.filepath, newContent, 'utf8');
    console.log('Written to', newFilepath || this.filepath);
  }
}

// Example usage:
// const handler = new EMakerFileHandler('example.emaker');
// handler.readAndDecode();
// handler.write('new content', 'new.emaker');

7. C class that can open any file of format .EMAKER and decode read and write and print to console all the properties from the above list

In C, we use structs for class-like behavior. This uses standard I/O for reading/writing.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>

typedef struct {
    char* filepath;
    char* content;
} EMakerFileHandler;

void init(EMakerFileHandler* handler, const char* filepath) {
    handler->filepath = strdup(filepath);
    handler->content = NULL;
}

void read_and_decode(EMakerFileHandler* handler) {
    FILE* file = fopen(handler->filepath, "r");
    if (!file) {
        perror("Error opening file");
        return;
    }

    fseek(file, 0, SEEK_END);
    long size = ftell(file);
    fseek(file, 0, SEEK_SET);

    handler->content = malloc(size + 1);
    fread(handler->content, 1, size, file);
    handler->content[size] = '\0';
    fclose(file);

    char* maker_name = "Unknown";
    char* def_pos = strstr(handler->content, "def ");
    if (def_pos) {
        def_pos += 4;
        while (*def_pos == ' ') def_pos++;
        char buffer[256];
        sscanf(def_pos, "%255s", buffer);
        maker_name = buffer;
    }

    struct stat st;
    stat(handler->filepath, &st);
    char mod_time[64];
    strftime(mod_time, sizeof(mod_time), "%Y-%m-%d %H:%M:%S", localtime(&st.st_mtime));

    int is_utf8 = 0;
    for (char* c = handler->content; *c; c++) {
        if ((unsigned char)*c > 127) {
            is_utf8 = 1;
            break;
        }
    }

    printf("File Extension: .emaker\n");
    printf("MIME Type: text/plain\n");
    printf("File Signature: None (text file)\n");
    printf("Encoding: %s\n", is_utf8 ? "UTF-8" : "ASCII");
    printf("Structure: E language source code\n");
    printf("Size: %ld bytes\n", size);
    printf("Last Modified: %s\n", mod_time);
    printf("Security Properties: Executes with no initial authority in E\n");
    printf("Content Type: E source code (maker)\n");
    printf("Defined Maker: %s\n", maker_name);
    printf("Full Content:\n%s\n", handler->content);
}

void write_file(EMakerFileHandler* handler, const char* new_content, const char* new_filepath) {
    const char* path = new_filepath ? new_filepath : handler->filepath;
    FILE* file = fopen(path, "w");
    if (!file) {
        perror("Error writing file");
        return;
    }
    fprintf(file, "%s", new_content);
    fclose(file);
    printf("Written to %s\n", path);
}

void destroy(EMakerFileHandler* handler) {
    free(handler->filepath);
    free(handler->content);
}

// Example usage:
// int main() {
//     EMakerFileHandler handler;
//     init(&handler, "example.emaker");
//     read_and_decode(&handler);
//     write_file(&handler, "new content", "new.emaker");
//     destroy(&handler);
//     return 0;
// }