Objects and binary files( Объекты и двоичные файлы )

Object and binary file

Stroing data in binary file
Binary file မ်ားသည္ ပိုမို၍ တိက် က်စ္လစ္မွဳ႕ရွိျပီး တစ္ခ်ိဳ႕ေသာအေျခအေနမ်ိဳးတြင္ operate ျပဳလုပ္ရန္ပိုမို၍ အဆင္ေျပလြယ္ကူေစသည္။
Binary file အား open ျပဳလုပ္ရန္အတြက္ access_mode ျဖစ္ေသာ ios::binary အား မျဖစ္မေန အသံုးျပဳရမည္။ ( တစ္ခ်ိဳ႕ေသာ C++ compiler မ်ားတြင္ ios::bin )
Output file အတြက္ object တစ္ခုအားတည္ေဆာက္ရန္အတြက္ ေအာက္ေဖာ္ျပပါအတိုင္းျပဳလုပ္ရမည္။
ofstream out_fil(“Outfil.dat”,ios::out | ios::binary);
if(!out_fil) { cerr<<”Error:Outfil.dat”<<endl;
                   exit(1);
               }
တည္ရွိျပီးသား binary_file တစ္ခုအား read ျပဳလုပ္လိုလွ်င္ ေအာက္ေဖာ္ျပပါအတိုင္း object တည္ေဆာက္ရမည္။
Ifstream in_fil(“Infil.dat”,ios::in | ios::binary);
if(!in_fil) {   cerr<<”Error:Infil.dat”<<endl;
                  exit(2);
              }

သို႕ေသာ္ တကယ့္လက္ေတြ႕တြင္ binary_file မ်ားအား operate ျပဳလုပ္ရန္အတြက္ တစ္ျခား ေသာ လုပ္ေဆာင္ခ်က္ အနည္းအား မိမိျပဳလုပ္လိုသည့္ ပုစၦာေပၚမူတည္၍ အနည္းငယ္ ထပ္မံ ေပါင္းထည့္ရန္ လိုအပ္ေပသည္။

Example. Write double type data into binary file.

#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <conio.h>
using namespace std;

Object and File Stream.Text file(Объекты и файловые потоки.Текстовые файлы)

Object and File Stream.Text file

Input/output stream of text file(Потоковый ввод/вывод дисковых файлов)

C++ Language တြင္ input/output operation မ်ားသည္ stream မွတစ္ဆင့္ လုပ္ေဆာင္ၾကသည္ ျဖစ္သည္။
Stream ဆိုသည္မွာ Logical သေဘာတရားအရသာ တည္ရွိသည္ျဖစ္ျပီး information မ်ားအား လက္ခံရယူရန္ႏွင့္ ျပန္လည္ထုတ္ေပးရန္အတြက္ ျပဳလုပ္ေပးသည္ျဖစ္သည္။
Keyboard ႏွင့္ Screen display မ်ားသည္ basic input/ouput Stream မ်ားျဖစ္ၾကသည္။ ၎တို႕၏ လုပ္ေဆာင္ခ်က္မ်ားသည္ text ဖိုင္မ်ားကဲ့သို႕ပင္ျဖစ္ၾကသည္။
Disk ဖိုင္မ်ားႏွင့္ အလုပ္လုပ္ရန္အတြက္ မျဖစ္မေန <fstream> ဟူေသာ header file ကို declare ျပဳလုပ္ရမည္ျဖစ္သည္။<fstream> ဟူေသာ file တြင္ ေအာက္ေဖာ္ျပပါ class မ်ားပါ၀င္သည္။
ifstream        - for input
ofstream       - for output
fstream         - read and write data in the same file

Disk file မ်ားႏွင့္ အလုပ္လုပ္နိုင္ရန္အတြက္ ၎အား ပထမဦးစြာ open ျပဳလုပ္ရန္လိုသည္။ထိုသို႕ open ျပဳလုပ္ရာတြင္ ios class တြင္ရွိေသာ open_mode အား define ျပဳလုပ္ေပးေသာ access_mode မ်ားကိုအသံုးျပဳရမည္ျဖစ္သည္။

Access_mode
Standard
Action
ate(attend)
Yes
When opening a file sets the file pointer to the end of file
binary (bin)
Yes
Open the file in binary representation
in
Yes
Open the file for reading (input)
out
Yes
Open the file for writing (output)


Text file(
Текстовые файлы)

Creating and write(Создание и запись)

Text file ေတြကိုတည္ေဆာက္ဖို႕အတြက္ ofstream class ရဲ႕ object အေနနဲ႕ တည္ေဆာက္ရမည္ျဖစ္ျပီး class ရဲ႕ constructor ရဲ႕ ပထမ parameter ေနရာမွာ ဖိုင္နာမည္ျဖစ္ျပီး ဒုတိယ parameter ေနရာမွာ access_mode ကိုေရးသားရမည္ျဖစ္သည္။
ofstream out_file(“out.txt”,ios::out);

Linux file system


Linux ဖိုင္ system သည္ hierchical စနစ္အား အေၿခၿပဳ၍ ရွင္းလင္းလြယ္ကူစြာ တည္ေဆာက္ ထားသည္ကို ေတြ႕ၿမင္နိဳင္သည္။ Distro တစ္ခုနွင့္ တစ္ခု တိက်စြာ မတူညီနိဳင္ေသာ္လည္း အေၿခခံ အက်ဥ္းဖ်ဥ္းအားၿဖင့္ ေအာက္ပါအတိုင္းေတြ႕ၿမင္ရမည္ၿဖစ္သည္။



Ubuntu Distro


(Ubuntu(oo-BOON-too) ဆိုတဲ့အဓိပါယ္ကေတာ့္ ေရွး Zulu (http://en.wikipedia.org/wiki/Zulu_people) နဲ႕ Xhose() တို႕ရဲ႕ စကားၿဖစ္ၿပီး “လူသားခ်င္းစာနာမွဳ႕” လို႕အဓိပါယ္ဖြင့္လို႕ရပါတယ္။)

Ubuntu ဆိုတာကလည္း မ်ားစြာေသာ Linux_distro ေတြထဲက linux_os တစ္ခုၿဖစ္ပါတယ္။Linux system ကိုအေၿခခံထားတဲ့ အမ်ိဳးမ်ိဳးေသာ brand ေတြကို Linux Distributions လို႕ေခၚဆိုေလ့ရွိၿပီး အတိုေကာက္အားၿဖင့္ Linux_distro လို႕ေခၚဆိုေလ့ရွိၾကပါတယ္။ Ubuntu သည္ လက္ရွိ popular အၿဖစ္ဆံုး Linux_os တစ္ခုၿဖစ္ၿပီး Debian အား base ထပ္မံၿပဳလုပ္ထားေသာ os တစ္ခုလည္းပင္ၿဖစ္သည္။ Debian ဆိုတာကေတာ့္ Debra နွင့္ Ian တို႕စတင္ ၿပဳလုပ္ခဲ့တဲ့ Linux distro တစ္ခုၿဖစ္ၿပီး os နယ္ပယ္မွာ ေတာ္ေတာ္ေလးအသိအမွတ္ၿပဳ ေကာင္းမြန္ခဲ့တဲ့ os တစ္ခုၿဖစ္ပါတယ္။ ဒါေပမယ့္ အရင္က ၎ os ဟာ update ၿပဳလုပ္ေပးနိဳင္မွဳ႕ user friendly installation နဲ႕ maintenance မွာ အနည္းငယ္ လိုအပ္ခ်က္ရွိခဲ့ပါတယ္။(#ယခင္အခ်ိန္က)

Ubuntu စတင္ခဲ့တာကေတာ့္ ေတာင္အာဖရိက အင္တာနက္ လုပ္ငန္း ထိပ္သီးပုဂိဳလ္ တစ္ေယာက္က user ေတြနဲ႕ friendly ၿဖစ္မယ့္ Linux_distro တစ္ခုကို ထပ္မံၿပဳလုပ္မယ္ဆံုးၿဖတ္ခဲ့ၿပီး Debian ကိုထပ္မံအေၿခခံ၍ ubuntu ဆိုတဲ့နာမည္နဲ႕ distro တစ္ခုၿပဳလုပ္ခဲ့ပါတယ္။ ေနာက္ပိုင္းမွာ သူက UK အေၿခစိုက္ Canonical Ltd တစ္ခုကို ဖြဲ႕စည္းခဲ့ၿပီး Ubuntu_Linux ကို support ၿပဳလုပ္ေစခဲ့ပါတယ္။

Open_source,Kernel,Shell

Open source 

ကၽြန္ေတာ္တို႕ linux ကိုေလ့လာလွ်င္ open source ဆိုေသာ စကားကိုအရင္ၾကားရမည္ၿဖစ္သည္။open source ၏အဓိပါယ္မွာ source code မ်ားအား ၿပဳၿပင္မြန္းမံနိဳင္ၿခင္း လိုအပ္သလို ၿပင္ဆင္နိဳင္ၿခင္း ၿဖစ္သည္။ ကၽြန္ေတာ္တို႕သည္ programmer တစ္ေယာကၿ္ဖစ္ၿပီး ကုဒ္မ်ားကို ဖတ္နိဳင္ ၿပင္နိဳင္ ထပ္မံမြမ္းမံ နိဳင္မည္ဆိုလွ်င္ ထို open source ဆိုေသာ စကားလံုးသည္ ပိုမိုအဓိပါယ္ရွိၿပီး ရိုးရွင္းမည္ ၿဖစ္သည္။

Kernel & shell

Kernel
Kernal ဆိုသည္မွာ operation system တစ္ခု၏ central လုပ္ေဆာင္ခ်က္တစ္ခုပင္ၿဖစ္သည္။ထို႕အတူ Linux system ၏အဓိက program တစ္ခုလည္းၿဖစ္သည္။၎သည္ Linux os တစ္ခု၏ resource မ်ားအား ထိန္းခ်ဳပ္ေပးသည္(ဥပမာdata,memory,file ေတြ management လုပ္သည့္အခါ)။Kernal ၏အဓိက လုပ္ေဆာင္ခ်က္သည္ computer hardware နဲ႕ အမ်ိဳးမ်ိဳးေသာ programs/application/shell ေတြ ၾကားတြင္ intermediate ( ၾကားခံဆက္သြယ္ေပးၿခင္း ) ၿပဳလုပ္ေပးၿခင္းပင္ၿဖစ္သည္။


What is Linux?


Linux သည္ window os နွင့္ Mac os ကဲ့သို႕ေသာ operation system တစ္ခုၿဖစ္ပါသည္. သို႕ေသာ္ Linux  သည္ entirely free  ၿဖစ္သည္။ 

Free ဟုဆိုရာတြင္ ပထမတစ္ခုသည္ free of cost ၿဖစ္သည္.(အၿခား os မ်ားကဲ့သို႕ ေငြေၾကးေပး၍ ၀ယ္ယူရန္ မလိုေပ)
ဒုတိယ တစ္ခုသည္ freedom ၿဖစ္သည္။ ကၽြန္ေတာ္တို႕ linux ကိုအသံုးၿပဳမည္ဆိုလွ်င္ ၎၏ sourcr code မ်ားလည္း၇ရွိနိဳင္မည္ၿဖစ္သည္။ထိုေၾကာင့္ ၎ linux os ကိုထပ္မံ modifiy ၿပဳလုပ္နိဳင္မည္ၿဖစ္သည္။ထို႕အတူ မ်ားစြာေသာ free software မ်ားရွိပါသည္။၎ထို႕ထဲမွ အမ်ားစုသည္ GNU General Public License(GPL) ေအာက္တြင္ထားရွိပါသည္။ GNU General Public License ဆိုသည္မွာ အရိုးရွင္းဆံုးေၿပာရရင္ copyleft ပင္ၿဖစ္သည္။Linux system ကို GNU tool မ်ားေပၚတြင္ အေၿခခံထားသည္ဟု ေၿပာဆိုနိဳင္ပါသည္။

ေနာက္တစ္ခ်က္သည္ ကၽြန္ေတာ္တို႕ linux အေၾကာင္းေၿပာရမည္ဆိုလွ်င္ UNIX အေၾကာင္းေမ့ထား၍ ရလိမ့္မည္ မဟုတ္ေပ။