레이블이 folder인 게시물을 표시합니다. 모든 게시물 표시
레이블이 folder인 게시물을 표시합니다. 모든 게시물 표시

2017년 10월 9일 월요일

linux에서 read-only filesystem의 file 혹은 folder/directory 제거하기

문제: linux에서 read-only filesystem이기에 지워지지않는 파일/폴더를 지우자.

해결:
1. cat /proc/mounts 로 mount 상태 보기
   해당 disk가 read-only 인지 확인 /dev/~ /media/ID/USB vfat ro, ~~~

2. mount -o remount,rw /dev/~(위에서 밑줄친 부분) 을 이용하여 read-write로 remount 시킴.

3. 1번 다시해서 확인.

4. rm으로 삭제하기
   rm -r -f 폴더명

2016년 4월 19일 화요일

visual studio 폴더 만들기

if (CreateDirectory(OutputFolder.c_str(), NULL) ||
    ERROR_ALREADY_EXISTS == GetLastError()){
    // 파일생성이 실패하고 그 이유가 이미 존재했기때문이라면.
    // DoSomthing(...)
}
else {
     // 만든경우 할일...
}

<출처: http://stackoverflow.com/questions/9235679/create-a-directory-if-it-doesnt-exist>

2015년 12월 8일 화요일

python에서 폴더 내 파일 읽어오기 (리스트 형태), 폴더 생성하기

<출처: http://stackoverflow.com/questions/3207219/how-to-list-all-files-of-a-directory-in-python>
// 특정 폴더의 파일(확장자가 ext인)을 읽어오고 싶은 경우 => 파일의 이름과 확장자만 리턴함. 
import os
def list_files(path, ext):
    filelist = []
    for name in os.listdir(path):
        if os.path.isfile(os.path.join(path, name)):
            if name.endswith(ext):
                filelist.append(name)
    return filelist
// 특정 폴더 및 그 하위폴더의 파일(확장자가 ext인)까지 읽어오고 싶은 경우.=> 경로, 파일의 이름과 확장자 모두 리턴함.
import os
def list_files_subdir(destpath, ext):
    filelist = []
    for path, subdirs, files in os.walk(destpath):
        for filename in files:
            f = os.path.join(path, filename)
            if os.path.isfile(f):
                if filename.endswith(ext):
                    filelist.append(f)
    return filelist
filelist = list_files_subdir(strdirectory_fc, 'txt') 
// 특정 폴더 및 그 하위폴더의 파일(확장자가 ext인)까지 읽어오고 싶은 경우.=> 경로, 파일의 이름을 별도로 리턴함. 
import os 
def list_files_subdir(destpath, ext):
    fullpathlist = []    
    folderlist = []
    filelist = []

    for path, subdirs, files in os.walk(destpath):
        for filename in files:
            f = os.path.join(path, filename)
            if os.path.isfile(f):
                if filename.endswith(ext):
                    fullpathlist.append(f)
                    folderlist.append(path)
                    filelist.append(filename)
    return fullpathlist, folderlist, filelist
// 특정 폴더 생성하기
# 폴더가 존재하는지 확인 후, 없으면 생성함.
strdirectory_fc = 'directory_name'
 
if not os.path.exists(strdirectory_fc):
    os.makedirs(strdirectory_fc)