def write_sample(binary, payload, path, filename):  
if not os.path.exists(path):<EOL><INDENT>os.makedirs(path)<EOL><DEDENT>sample = os.path.join(path, filename)<EOL>if binary:<EOL><INDENT>with open(sample, "<STR_LIT:wb>") as f:<EOL><INDENT>f.write(base64.b64decode(payload))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with open(sample, "<STR_LIT:w>") as f:<EOL><INDENT>f.write(payload)<EOL><DEDENT><DEDENT>
This function writes a sample on file system.

Args:
    binary (bool): True if it's a binary file
    payload: payload of sample, in base64 if it's a binary
    path (string): path of file
    filename (string): name of file
    hash_ (string): file hash