unix-es
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
unix-es [2015/05/12 13:14] – [Permisos] lmateu | unix-es [2016/11/15 13:15] (actual) – [Características de un archivo] lmateu | ||
---|---|---|---|
Línea 173: | Línea 173: | ||
/* Uso: micp from to */ | /* Uso: micp from to */ | ||
#include < | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
#include < | #include < | ||
- | #include < | ||
- | #include < | ||
#include < | #include < | ||
+ | #include < | ||
| | ||
- | | + | |
- | va_list args; | + | |
- | + | ||
- | va_start(args, | + | |
- | fprintf(stderr, | + | |
- | vfprintf(stderr, | + | |
- | fprintf(stderr, | + | |
- | va_end(args); | + | |
- | + | ||
- | exit(1); | + | |
- | } | + | |
| | ||
int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||
- | int f1, f2; | + | int in, out; |
ssize_t n; | ssize_t n; | ||
- | char buf[BUFSIZ]; | + | char buf[SIZE]; |
- | + | ||
- | if (argc!=3) | + | if (argc!=3) |
- | | + | |
- | + | | |
- | if ((f1= open(argv[1], | + | } |
- | | + | |
- | + | if ((in= open(argv[1], | |
- | if ((f2= creat(argv[2], | + | |
- | | + | |
- | + | } | |
+ | | ||
+ | if ((out= creat(argv[2], | ||
+ | | ||
+ | | ||
+ | } | ||
+ | | ||
/* usando stats se pueden mantener los permisos */ | /* usando stats se pueden mantener los permisos */ | ||
- | | + | |
- | while ((n= read(f1, buf, BUFSIZ))>0) | + | while ((n= read(in, buf, SIZE))> |
- | if(write(f2, buf, n)!=n) | + | if (write(out, buf, n)!=n) |
- | | + | |
- | + | | |
- | if (n<0) | + | } |
- | | + | } |
+ | | ||
+ | if (n< | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | close(in); | ||
+ | close(out); | ||
+ | | ||
return 0; | return 0; | ||
} | } | ||
- | |||
==== Cambiar los permisos de un archivo ==== | ==== Cambiar los permisos de un archivo ==== | ||
Línea 232: | Línea 237: | ||
char *path; | char *path; | ||
unlink(path); | unlink(path); | ||
+ | |||
+ | ==== Cambiar el nombre de un archivo ==== | ||
+ | |||
+ | Se usa la funcion //rename//: | ||
+ | |||
+ | #include < | ||
+ | char *oldpath, *newpath; | ||
+ | rename(newpath, | ||
==== Crear un link duro ==== | ==== Crear un link duro ==== | ||
Línea 347: | Línea 360: | ||
st_size | st_size | ||
st_atime | st_atime | ||
- | st_ctime | + | st_ctime |
st_mtime | st_mtime | ||
unix-es.1431436491.txt.gz · Última modificación: 2015/05/12 13:14 por lmateu