0% found this document useful (0 votes)
13 views25 pages

OS HOBBY (1) - Merged

The document presents a project report on a Basic File Compression Tool developed by students in the Department of CSE(AI & ML) at CMR Engineering College. It discusses the tool's functionality, algorithms used for compression, and its applications in optimizing storage and improving data transfer efficiency. The report also highlights the advantages and disadvantages of file compression, concluding that while beneficial, it has limitations that need to be managed.

Uploaded by

shaiksubhani8433
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views25 pages

OS HOBBY (1) - Merged

The document presents a project report on a Basic File Compression Tool developed by students in the Department of CSE(AI & ML) at CMR Engineering College. It discusses the tool's functionality, algorithms used for compression, and its applications in optimizing storage and improving data transfer efficiency. The report also highlights the advantages and disadvantages of file compression, concluding that while beneficial, it has limitations that need to be managed.

Uploaded by

shaiksubhani8433
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

A Hobby Project Report on

BASIC FILE COMPRESSION TOOL


Submitted in partial fulfilment of the requirement of the
lab

OPERATING SYSTEM LAB

II-B. TECH. I SEM


in
Department of CSE(AI & ML)
Submitted by
L.SREEJA VARMA (238R1A6629)
CH.NIRANJAN KUMAR
K.SURYA VAMSHI (238R1A6609)
SHAIK SUBHANI
(238R1A6632)
Under the guidance
(238R1A6653)
Mrs.G.Mrunlini

Assistant Professor Department of CSE(AL&ML)

DEPARTMENT OF CSE(AI & ML)

CMR ENGINEERING COLLEGE


UGC AUTONOMOUS

(Accredited by NBA, Approved by AICTE,


Affiliated to JNTU) Kandlakoya, Medchal
Road,
Hyderabad-501401

2024-2025
CMR ENGINEERING COLLEGE

UGC AUTONOMOUS
(Approved by AICTE, Affiliated to JNTU, Kukatpally,
Hyderabad) Kandlakoya, Medchal Road, Hyderabad-501401.
DEPARTMENT OF CSE(AI & ML)

CERTIFICATE

This is to certify that a Lab project entitled with: “BASIC FILE COMPRESSION TOOL”

is being submitted by L.Sreeja varma(238R1A6629),Ch.Niranjan kumar(238R1A6609),Shaik

Subhani(238R1A6653),K.Surya vamsi(238R1A6632) in partial fulfilment of the requirement

for completion of the OPERATING SYSTEMS LAB II B.Tech I- Semester is a record of a

bonafide work carried out under guidance and supervision

Internal Guide External Guide


Mrs.G.Mrunalini Dr.M.Kumara Swamy
Assistant Professor Professor & Hod
Department of CSE(AI&ML) Department of CSE(AI&ML)
CMREC,Hyderabad CMREC,Hyderabad
ACKNOWLEDGEMENT

We are extremely grateful to Dr.M.KUMARA SWAMY,Head of Department, Department of

CSE(AI & ML),CMREC for their inspiration and valuable guidance during entire duration.

We are extremely thankful to our Professor MRS.G.MURNALINI , Department of CSE(AI &

ML) department for his constant guidance,encouragement and moral support throughout the

project. We express our thanks to all staff members and friends for all the help and

coordination extended in bringing out this mini project successfully in time.

L.SREEJA VARMA (238R1A6629)


CH.NIRANJAN KUMAR (238R1A6609)
K.SURYA VAMSHI
SHAIK SUBHANI (238R1A6632)

(238R1A6653)
ABSTRACT

File compression is a fundamental feature in modern operating systems that optimizes storage space
and enhances data transfer efficiency. A basic file compression tool employs algorithms to reduce
file sizes by eliminating redundancies, encoding data efficiently, and often utilizing lossless
compression techniques to preserve original content integrity. Such tools are critical for managing
limited storage resources, streamlining file sharing, and improving system performance. This paper
introduces a basic file compression tool, discussing its architecture, algorithms (e.g., Huffman
coding or LZW), and integration into operating systems. It highlights the tool’s utility in balancing
speed and compression ratio, ensuring user-friendly operation while maintaining compatibility with
various file formats. This approach aims to provide a practical solution for everyday compression
needs in diverse computing environments.
INTRODUCTION

Operating systems incorporate compression tools to empower users with straightforward methods
to manage large files and directories without external software dependencies. These tools are
particularly valuable in scenarios with limited storage resources or bandwidth constraints, where
every byte saved can make a significant difference.

This paper presents a basic file compression tool designed for operating systems, focusing on its
functionality, ease of use, and algorithmic efficiency. By integrating this tool into file management
processes, users can experience streamlined storage and improved data handling capabilities. The
tool is aimed at addressing common challenges in data management, offering a simple yet effective
solution for compression needs.

The core principle of file compression lies in utilizing algorithms that reduce file size while
maintaining data integrity. Lossless compression techniques, such as Huffman coding or
Lempel-Ziv-Welch (LZW), are commonly used to ensure that the original data can be fully restored
upon decompression. This makes them suitable for system-critical files, documents, and software
applications where accuracy is paramount.
LITERATURE SURVEY

File compression has been a vital area of research and development, especially in operating systems
where efficient storage management and data transfer are critical. Over the years, various algorithms,
techniques, and tools have been proposed to optimize file compression performance. This section
provides an overview of existing studies, methodologies, and tools relevant to the development of a
basic file compression tool.

1. Compression Algorithms
2. File Compression Tools
3. Compression in Operating Systems
4. Challenges in Compression
5. Advancements in Compression

HOW BASIC COMPRESSION TOOL WORKS


A basic file compression tool works by reducing the size of files through encoding techniques
that eliminate redundancies or optimize data representation. These tools use algorithms to
compress files into smaller sizes without losing essential information (lossless compression)
or with acceptable quality loss (lossy compression, for multimedia data). Below is an
overview of how a basic file compression tool typically operates:

1. Input File Selection


The user selects the file or group of files to be compressed.

2. Analysis of Data
The tool scans the file to identify patterns, redundancies, or frequently occurring

data.

3. Application of Compression Algorithms


The core of the tool is the compression algorithm, which transforms the original
file into a more compact form. Common techniques include:

4. Output File Creation


The compressed data is written to a new file, typically with a specific
extension (e.g., .zip, .gz, or .lz).

5. Decompression Support
The tool ensures that the compressed file can be decompressed to restore the
original data.
This involves reversing the compression process:
Reconstructing the original data using stored metadata and the applied algorithm.
SOURCE CODE

#include <stdio.h>
#include <stdlib.h>
#include
<string.h>
#include <zlib.h>

void compress_file(const char *input_file, const char *output_file)


{ FILE *in = fopen(input_file, "rb");
if (!in) {
perror("Error opening input
file"); return;
}
fseek(in, 0, SEEK_END);
long input_size =
ftell(in); fseek(in, 0,
SEEK_SET);
unsigned char *data =
(unsigned char
*)malloc(input_size);
if (!data) {
perror("Error allocating memory for input
file"); fclose(in);
return;
}
fread(data, 1, input_size,
in); fclose(in);
uLongf compressed_size =
compressBound(input_size);
unsigned char *compressed_data = (unsigned char
*)malloc(compressed_size); if (!compressed_data) {
perror("Error allocating memory for compressed
data"); free(data);
return;
}
int result = compress(compressed_data, &compressed_size, data, input_size);
if (result != Z_OK) {
printf("Error compressing data: %d\n", result);
free(data);
(compressed_data)
if (!out) {
perror("Error opening output
file"); free(data);
free(compressed_data);
return;
}
fwrite(compressed_data, 1, compressed_size,
out); fclose(out);
printf("File '%s' compressed successfully to '%s'.\n", input_file,
output_file); free(data);
free(compressed_data);
}
void decompress_file(const char *input_file, const char *output_file)
{ FILE *in = fopen(input_file, "rb");
if (!in) {
perror("Error opening input
file"); return;
}
fseek(in, 0, SEEK_END);
long compressed_size =
ftell(in); fseek(in, 0,
SEEK_SET);
unsigned char *compressed_data = (unsigned char
*)malloc(compressed_size); if (!compressed_data) {
perror("Error allocating memory for compressed
file"); fclose(in);
return;
}
fread(compressed_data, 1, compressed_size,
in); fclose(in);
uLongf decompressed_size = compressed_size
* 4;
unsigned char *decompressed_data = (unsigned char *)malloc(decompressed_size);
if (!decompressed_data) {
perror("Error allocating memory for decompressed data");
free(compressed_data);
return; }
int result = uncompress(decompressed_data, &decompressed_size, compressed_data,
compressed_size);
if (result != Z_OK) {
printf("Error decompressing data: %d\n", result);
free(compressed_data);
free(decompressed_data);
return;
}
FILE *out = fopen(output_file,
"wb"); if (!out) {
perror("Error opening output file");
free(compressed_data);
free(decompressed_data);
return;
}
fwrite(decompressed_data, 1, decompressed_size,
out); fclose(out);
printf("File '%s' decompressed successfully to '%s'.\n",
input_file, output_file);

free(compressed_data);
free(decompressed_data);
}
int main(int argc, char *argv[]) {
if (argc != 4) {
printf("Usage: %s <compress|decompress> <input_file> <output_file>\n", argv[0]);
return 1;
}

const char *operation = argv[1];


const char *input_file = argv[2];
const char *output_file =
argv[3];

if (strcmp(operation, "compress") == 0) {
compress_file(input_file, output_file);
} else if (strcmp(operation, "decompress") == 0)
{ decompress_file(input_file, output_file);
} else {
printf("Invalid operation. Use 'compress' or 'decompress'.\
n"); return 1; }
return 0;
}
ADVANTAGES

1. Storage Space Optimization


Reduces File Sizes: Compressing files minimizes storage usage, allowing users to store more
data on the same device.

Efficient Archiving: Ideal for archiving infrequently used files to save


disk Space.

2. Faster Data Transfer

Quicker Uploads/Downloads: Smaller files reduce the time needed for data
transfer over networks or the internet.

Bandwidth Savings: Compressing data before transmission helps reduce network


bandwidth usage, especially for large files.

3. Easy File Management


Single Compressed File: Combines multiple files into one compressed archive,
simplifying organization and distribution.

Convenient Sharing: Compressed files are easier to email or share through file-sharing
platforms.

4. Compatibility and Accessibility


Widely Supported Formats: Formats like .zip and .gz are supported across various
operating systems and applications.

Easy Decompression: Decompression restores the original file without data loss, ensuring
accessibility.

5. Improved System Performance


Faster File Operations: Smaller file sizes lead to quicker file copying, moving, and reading
operations
DISADVANTAGES

1. Processing Overhead
Time Consumption: Compressing and decompressing large files can take considerable
time, especially on slower systems.

CPU Usage: Compression algorithms may require significant processing power, which
can slow down other operations.

2. Limited Compression for Certain Files

Already Compressed Files: Files like videos (e.g., MP4) or images (e.g., JPEG) are already
optimized and may not compress further, resulting in negligible size reduction.
Random Data: Files with random or encrypted data cannot be compressed effectively.

3. Loss of Accessibility During Compression


Archive Files: Compressed files must be decompressed to access individual components,
which can be inconvenient.

Temporary Inaccessibility: A compressed file is unusable until decompressed,


adding extra steps for access.

4 .Risk of Data Loss


Corruption: If the compressed file is damaged or corrupted, the entire file or archive may
become unusable.

Dependency Tools: Some compressed formats require specific tools or software for
decompression, leading to compatibility issues.

5.STORAGE TRADE-OFFS

Minimal gain for small files: Compressing small files may result in negligible
space savings while adding unnecessary complexity
APPLICATIONS

1.Storage Optimization
Reducing Disk Space Usage: Compressing files allows users to store more data
within the same storage capacity.

1. Data Transmission
Faster File Transfers: Smaller file sizes reduce upload/download times, optimizing
data transfer over networks.

2. Improved Performance
Speeding Up File Access: Some operating systems and applications read compressed files faster
than uncompressed files due to reduced I/O operations.

3. Software Development and Distribution


Packaging Software: Developers use compression to bundle multiple files or executables into a
single compressed file for easy distribution.

4. Multimedia Management
Image Compression: Reducing image file sizes without compromising quality for websites, apps,
or digital platforms.

5. File Sharing
Peer-to-Peer Sharing: Compression is widely used in file-sharing networks to minimize data size
and reduce transfer times.
CONCLUSION

A basic file compression tool is a vital utility in modern operating systems, offering significant
advantages in terms of storage optimization, faster data transfer, and improved performance. By
reducing file sizes, these tools help conserve valuable storage space, streamline file management,
and speed up data transmission over networks. They are widely used in various applications, from
personal file handling to enterprise-level backup and data sharing.

However, while file compression tools are beneficial, they come with certain limitations. These
include processing overhead, potential compatibility issues, and the risk of data loss or file
corruption. Additionally, some file types may not benefit from compression, and lossy
compressionmethods can lead to quality degradation in media files.

In conclusion, a basic file compression tool is a highly useful and practical tool, making it an
indispensable part of the file management process in operating systems, provided its limitations are
considered and managed effectively.
REFERENCES

•Books
•Research Papers and Articles
•Websites and Online Resources
•Online Tools and Libraries
•Tools and Libraries Documentation

You might also like