Code Explainers

Code explainers tagged #filesystem

python
import os
import shutil
import tempfile
from contextlib import contextmanager

Transactional file operations in Python

transactions rollback closures
Intermediate 8 steps
php
<?php
 
namespace App\Support;
 

Recursively finding files with SPL iterators in PHP

recursion iterators filesystem
Intermediate 7 steps
python
from pathlib import Path
from collections import defaultdict
 
from PIL import Image

Finding near-duplicate images by perceptual hash

perceptual-hashing clustering hamming-distance
Intermediate 9 steps
go
package fsutil
 
import (
	"io/fs"

Walking a directory tree to find large files in Go

filesystem recursion closures
Intermediate 7 steps
php
<?php
 
namespace App\Cache;
 

A content-hashed fragment cache in PHP

caching content-hashing atomic-writes
Intermediate 10 steps
go
package server
 
import (
	"net/http"

Serving cached static assets in Gin

caching static-files middleware
Intermediate 7 steps
python
import os
import time
from pathlib import Path
 

Polling a directory for file changes in Python

polling filesystem set-operations
Intermediate 8 steps
rust
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
 

Recursive file search by extension in Rust

recursion filesystem error-handling
Intermediate 8 steps
python
from pathlib import Path
 
 
def print_tree(root, prefix="", show_hidden=False):

Printing a directory tree with recursion

recursion filesystem sorting
Intermediate 6 steps
python
import os
import tempfile
from pathlib import Path
from typing import Union

How atomic file writes work in Python

atomicity filesystem durability
Advanced 7 steps