EvoTalk

Posts Tagged ‘file

03 十二月, 2008

C List Files on Windows

Posted by: asd In: C++| Code Snippet| 程式設計

c 列舉檔名
view plain

C++:

#include   <stdio.h>

#include   <io.h>

#include   <time.h>

 

void main(void)

{

    struct   _finddata_t   c_file;

    long   hFile;

 

    if(   (hFile = _findfirst(   "*.* ",   &c_file   )) == -1L)

        printf(   "No   *.c   files   in   current   directory!n "   );

    else

    {

        [...]

Tags: ,

24 十一月, 2008

Detect File or Folder Change on Windows

Posted by: asd In: C++| Code Snippet| 程式設計

Spying a file system
FindFirstChangeNotification & Shell_NotifyIcon together... again

Tags: ,

03 八月, 2007

Remove WAV File Header

Posted by: asd In: Code Snippet| Perl| 程式設計

此 script 的作用:批次移除 wav 檔的檔頭,產生 pcm 檔
使用方法
BatchRipWavHdr.pl WavLst.txt
WavLst.txt 為來源wav檔的路徑列表,使用前需先設定產生的 pcm 檔要放在哪個目錄「$dest_prefix」,若要依照來源目錄層次第 n 層來存放,可設定「$sublayer」
view plain

PERL:

#!/usr/bin/perl -w

#

#動態的為Wav檔求算出其Header的size

#

use File::Path;

if(scalar @ARGV!=1)

{

print "Usage: BatchRipWavHdr.pl WavLst.txt" ;

exit;

}

 

$dest_prefix='C:\Tel100_PCM';

#$dest_prefix='H:\Spelled_Spoken\BatchRipWavHeader';

$sublayer='1';

#$hdr='48'; #bytes

$number=0;

while(&lt;&gt;)

{

#Y:\cdrom\spelled_spoken\speech\alphabet\23\call2316.alphabet.wav

chomp;

$source=$_;

$hdr=44;#&amp;CheckHeaderByte($source);

@dir=split /\\/,$_;

@dir=@dir[$sublayer..$#dir];

$pcm=pop @dir;

$pcm=~s/wav$/pcm/i;

$dir=join '\\',@dir;

$dir.='\\';

$dir=$dest_prefix.'\\'.$dir if($dest_prefix ne '');

 

eval { mkpath($dir) };

if ($@) {

print "Couldn't create $dir: $@";

}

 

$dest=$dir.$pcm;

 

open SOURCE,"$source" or die "$!";

open DEST,"&gt;$dest" or die "$!";

seek SOURCE,$hdr,0;

while(sysread SOURCE,$buf,4096)

{

syswrite DEST,$buf,4096;

}

 

print ++$number,"\r";

}

 

sub CheckHeaderByte

{

my ($wav)=@_;

my($out,$buf,$data,$hdr);

open WAV,"$wav" or die "WAV:$!";

binmode [...]

Tags:

09 三月, 2007

Perl File Flush

Posted by: asd In: Code Snippet| Perl| 程式設計

Set $| to a non-zero value. grep the man page for "autoflush" for further information.
view plain

PERL:

$oldhandle = select(FILEHANDLE);

$| = 1;

select($oldhandle);

Tags: ,

21 一月, 2007

MFC 讀取文字檔的方法

Posted by: asd In: C++| Code Snippet| 程式設計

轉貼自 Sysoft 時空論壇,順便介紹msdn沒有說明的函數 AfxExtractSubString
view plain

C++:

// Open the text file we want

CFile cfFile ("C:\TextFile.txt", CFile::modeNoTruncate | CFile::modeRead);

 

CArchive ar (&amp;cfFile, CArchive::load); // Load its contents into a CArchive

 

// Initialise the variable which holds each line's contents

CString strLine = "";

if(!ar.ReadString(strLine))

// Read the first line of the CArchive into the variable

return; // Failed, so quit out

 

do // Repeat while there [...]

Tags: ,

Page 1 of 212