Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
redes1-trabalho1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo Machado
redes1-trabalho1
Commits
649a779c
Commit
649a779c
authored
9 years ago
by
Eduardo Machado
Browse files
Options
Downloads
Patches
Plain Diff
duplicado
parent
0db79da1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miniShellSRC/miniShell.cpp
+0
-81
0 additions, 81 deletions
miniShellSRC/miniShell.cpp
with
0 additions
and
81 deletions
miniShellSRC/miniShell.cpp
deleted
100644 → 0
+
0
−
81
View file @
0db79da1
/* Implementado por: Eduardo Machado e Victor Perszel */
/* 2015 */
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<errno.h>
#include
<dirent.h>
#include
<unistd.h>
#include
<sys/stat.h>
#include
<sys/types.h>
#include
<iostream>
#include
<string>
#include
<fstream>
#include
<map>
#include
<cstdlib>
#include
<cmath>
#include
<vector>
using
namespace
std
;
int
lsParameter
(
string
parameter
){
if
(
parameter
==
"."
)
return
1
;
else
if
(
parameter
==
"-a"
)
return
2
;
else
if
(
parameter
==
"-l"
)
return
3
;
else
if
(
parameter
==
"-la"
)
return
4
;
else
return
-
1
;
}
int
lsMini
(
string
parameter
,
char
*
currentPath
){
string
mostra
,
temp
,
path
,
lsAux
,
fileName
;
ifstream
lsFile
;
path
=
currentPath
;
/* Para dar um ls apenas, é necessário escrever "ls ." */
/* Precisamos pensar em um jeito de concertar isso. */
switch
(
lsParameter
(
parameter
)){
case
1
:
lsAux
=
"ls > "
+
path
+
"/ls.txt"
;
system
(
lsAux
.
c_str
());
break
;
case
2
:
lsAux
=
"ls -a > "
+
path
+
"/ls.txt"
;
system
(
lsAux
.
c_str
());
break
;
case
3
:
lsAux
=
"ls -l > "
+
path
+
"/ls.txt"
;
system
(
lsAux
.
c_str
());
break
;
case
4
:
lsAux
=
"ls -la > "
+
path
+
"/ls.txt"
;
system
(
lsAux
.
c_str
());
break
;
case
-
1
:
puts
(
"Parâmetro de ls inválido."
);
return
-
1
;
break
;
}
printf
(
"
\n
"
);
// Abertura do arquivo de entrada.
fileName
=
path
+
"/ls.txt"
;
lsFile
.
open
(
fileName
.
c_str
(),
ios
::
in
);
lsFile
.
seekg
(
0
);
// Leitura do arquivo.
while
(
getline
(
lsFile
,
temp
))
{
mostra
+=
temp
+
"
\n
"
;
}
// Remove arquivo ls.txt
remove
(
fileName
.
c_str
());
cout
<<
"mostra:"
<<
mostra
<<
endl
;
return
0
;
}
int
cdMini
(
string
intendedDirectory
){
int
errorTest
;
errorTest
=
chdir
(
intendedDirectory
.
c_str
());
return
errorTest
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment